├── src ├── settings │ ├── channels.json │ └── settings.json ├── functions │ ├── functions.js │ └── Modal.js ├── models │ └── privatevoice.js ├── events │ ├── interactionCreate.js │ ├── voiceStateUpdate.js │ ├── ready.js │ ├── channelCheck.js │ ├── button.js │ └── modal.js ├── commands │ ├── tarih.js │ ├── gir.js │ └── özelOda.js └── util │ ├── event.js │ └── slash.js ├── package.json ├── index.js ├── README.md └── LICENSE /src/settings/channels.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": { 3 | "vparent": "958432029488341022", 4 | "tparent": "958432049121865738", 5 | "log": "log" 6 | } 7 | } -------------------------------------------------------------------------------- /src/functions/functions.js: -------------------------------------------------------------------------------- 1 | client.findChannel = function (channelName) { 2 | try { 3 | return client.channels.cache.find(x => x.name === channelName) 4 | } catch (err) { 5 | return undefined; 6 | } 7 | }; -------------------------------------------------------------------------------- /src/settings/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "guild": { 3 | "id": "" 4 | }, 5 | "bot": { 6 | "owner": "919663047923101736", 7 | "mongoURL": "mongodb+srv://:@/privateVoiceModal", 8 | "token": "" 9 | } 10 | } -------------------------------------------------------------------------------- /src/models/privatevoice.js: -------------------------------------------------------------------------------- 1 | module.exports = mongoose.model("privatevoice", mongoose.Schema({ 2 | memberID: {type: String, default: null}, 3 | vchannelID: {type: String, default: null}, 4 | tchannelID: {type: String, default: null}, 5 | password: {type: String, default: null}, 6 | leaveDate: {type: Number, default: Date.now()}, 7 | })); -------------------------------------------------------------------------------- /src/events/interactionCreate.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | event: "interactionCreate", 3 | oneTime: false, 4 | ws: false, 5 | run: async (i) => { 6 | if (!i.isCommand()) return; 7 | const commandCheck = i.client.commands.get(i.commandName); 8 | 9 | if (!commandCheck) { 10 | return console.log(`Komut bulanamadı" '${i.commandName}'`); 11 | } else { 12 | await commandCheck.run(i); 13 | } 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /src/commands/tarih.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require("@discordjs/builders"); 2 | let moment = require('moment'); 3 | require('moment-duration-format'); 4 | moment.locale('tr'); 5 | 6 | module.exports = { 7 | data: new SlashCommandBuilder() 8 | .setName('tarih') 9 | .setDescription('tarih'), 10 | run: async (interaction) => { 11 | interaction.reply({content: `Sunucu tarihi : ${moment(interaction.guild.createdTimestamp).format("LLL")}`}) 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /src/events/voiceStateUpdate.js: -------------------------------------------------------------------------------- 1 | const privateVoiceDatabase = require('../models/privatevoice'); 2 | 3 | module.exports = { 4 | event: "voiceStateUpdate", 5 | oneTime: false, 6 | ws: false, 7 | run: async (oldState, enwState) => { 8 | let privateVoiceData = await privateVoiceDatabase.findOne({ memberID: oldState.id }); 9 | if (privateVoiceData && (!oldState.channel || (oldState.channel && oldState.channel.id == privateVoiceData?.channelID))) { 10 | privateVoiceData.leaveDate = Date.now(); 11 | await privateVoiceData.save(); 12 | } 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /src/util/event.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | 3 | const event = { 4 | load: async (client) => { 5 | const events = fs 6 | .readdirSync("./src/events").filter(file => file.endsWith('.js')) 7 | 8 | events.forEach(event => { 9 | const eventFile = require(`../events/${event}`) 10 | if (eventFile.oneTime) { 11 | client.once(eventFile.event, (...args) => eventFile.run(...args)) 12 | } else if(eventFile.ws) { 13 | client.ws.on(eventFile.event, (...args) => eventFile.run(...args)) 14 | } else { 15 | client.on(eventFile.event, (...args) => eventFile.run(...args)) 16 | } 17 | }) 18 | } 19 | } 20 | 21 | module.exports = event; -------------------------------------------------------------------------------- /src/functions/Modal.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios'); 2 | 3 | module.exports = class Modal { 4 | constructor(interaction, title, modalId, components = []) { 5 | this.interaction = interaction; 6 | this.title = title; 7 | this.modalId = modalId; 8 | this.components = components; 9 | this.new(); 10 | } 11 | async new() { 12 | await client.api.interactions(this.interaction.id, this.interaction.token).callback.post({ 13 | data: { 14 | type: 9, 15 | data: { 16 | title: this.title, 17 | custom_id: this.modalId, 18 | components: this.components, 19 | }, 20 | }, 21 | }); 22 | } 23 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "slash-handler", 3 | "version": "1.0.0", 4 | "description": "Discord.js V13 Slash Commands Handler", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@discordjs/builders": "^0.6.0", 14 | "@discordjs/rest": "^0.1.0-canary.0", 15 | "axios": "^0.26.1", 16 | "discord-api-types": "^0.22.0", 17 | "discord.js": "^13.6.0", 18 | "moment": "^2.29.1", 19 | "moment-duration-format": "^2.3.2", 20 | "mongoose": "^5.12.13", 21 | "ora": "^5.4.1" 22 | }, 23 | "devDependencies": { 24 | "eslint-plugin-security": "^1.4.0" 25 | }, 26 | "optionalDependencies": { 27 | "bufferutil": "^4.0.3" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Util 2 | const { Client, Collection } = require('discord.js') 3 | const mongoose = global.mongoose = require('mongoose'); 4 | const settings = global.settings = require('./src/settings/settings.json') 5 | const channels = global.channels = require('./src/settings/channels.json') 6 | const ora = global.ora = require('ora'); 7 | 8 | //Client 9 | const client = (global.client = new Client({ intents: [32767] })) 10 | 11 | //Functions 12 | require('./src/functions/functions'); 13 | 14 | //Mongoose 15 | mongoose.connect(settings.bot.mongoURL, { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false }) 16 | 17 | // Slash Commands 18 | require('./src/util/event').load(client); 19 | const slash = require('./src/util/slash') 20 | 21 | // Commands 22 | client.commands = new Collection() 23 | 24 | //Login 25 | client.login(settings.bot.token) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # v13-private-voice 2 | 3 | Ne yapayım bunu daha geliştireyim mi? :D 4 | 5 | Eğik çizgi komutu ve modal ile birlikte! 6 | 7 | ![image](https://user-images.githubusercontent.com/79569914/161393531-a2a8316a-574a-4674-9256-fafee82a248f.png) 8 | ![image](https://user-images.githubusercontent.com/79569914/161393628-6c0d19e9-84d0-452c-8743-c82aef13bb0c.png) 9 | ![image](https://user-images.githubusercontent.com/79569914/161393645-41bd7d57-8fc4-4e92-a8a3-2be6e7e06e40.png) 10 | ![image](https://user-images.githubusercontent.com/79569914/161393543-9ab99146-1661-4197-82c9-d1a1d9a333d8.png) 11 | 12 | ![image](https://user-images.githubusercontent.com/79569914/161393655-56a43560-5757-4ddf-801d-bc5fac6eca9a.png) 13 | 14 | Discord adresim; `respect#1000` (919663047923101736) 15 | 16 | **Star** atmayı unutmayın. 🌟 17 | 18 | ![](https://komarev.com/ghpvc/?username=respect0&color=dc143c) 19 | -------------------------------------------------------------------------------- /src/events/ready.js: -------------------------------------------------------------------------------- 1 | // Util 2 | const fs = require("fs"); 3 | 4 | // Slash Commands 5 | const slash = require("../util/slash"); 6 | 7 | // CLI 8 | const botLoader = ora("Bot aktif ediliyor.").start(); 9 | 10 | module.exports = { 11 | event: "ready", 12 | oneTime: true, 13 | ws: false, 14 | run: async (client) => { 15 | const commandFiles = fs 16 | .readdirSync("./src/commands") 17 | .filter((file) => file.endsWith(".js")); 18 | 19 | let commandsArray = []; 20 | commandFiles.forEach((file) => { 21 | const command = require(`../commands/${file}`); 22 | client.commands.set(command.data.name, command); 23 | 24 | commandsArray.push(command); 25 | }); 26 | 27 | const finalArray = commandsArray.map((e) => e.data.toJSON()); 28 | slash.register(client.user.id, finalArray); 29 | 30 | botLoader.succeed(`${client.user.tag}, başarıyla giriş yaptım.`); 31 | }, 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 frkn :) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/util/slash.js: -------------------------------------------------------------------------------- 1 | const slash = { 2 | register: async (clientId, commands) => { 3 | const loadSlash = ora(`Eğik çizgi komutları yükleniyor.`).start(); 4 | 5 | const { REST } = require("@discordjs/rest"); 6 | const { Routes } = require("discord-api-types/v9"); 7 | 8 | const rest = new REST({ version: "9" }).setToken(settings?.bot?.token); 9 | 10 | try { 11 | const guildId = settings.guild?.id; 12 | if (!isNaN(guildId)) { 13 | await rest 14 | .put(Routes.applicationGuildCommands(clientId, guildId), { 15 | body: commands, 16 | }) 17 | .then(() => { 18 | return loadSlash.succeed(`Eğik çizgi komutları sunucuya yüklendi.`); 19 | }); 20 | } else { 21 | await rest 22 | .put(Routes.applicationCommands(clientId), { body: commands }) 23 | .then(() => { 24 | loadSlash.succeed(`Eğik çizgi komutları yüklendi.`); 25 | }); 26 | } 27 | } catch (error) { 28 | loadSlash.warn(`Eğik çizgi komutları yüklenemedi, hata: \n ${error}`); 29 | } 30 | }, 31 | }; 32 | 33 | module.exports = slash; 34 | -------------------------------------------------------------------------------- /src/events/channelCheck.js: -------------------------------------------------------------------------------- 1 | const privateVoiceDatabase = require('../models/privatevoice'); 2 | 3 | module.exports = { 4 | event: "ready", 5 | oneTime: true, 6 | ws: false, 7 | run: async (client) => { 8 | let guild = client.guilds.cache.get(settings.guild.id); 9 | if (!guild) return; 10 | setInterval(async () => { 11 | await check(guild) 12 | }, 10000) 13 | }, 14 | }; 15 | 16 | async function check(guild) { 17 | let privateVoiceData = await privateVoiceDatabase.find(); 18 | if (privateVoiceData.length <= 0) return; 19 | privateVoiceData.map(async (data, i) => { 20 | setTimeout(async () => { 21 | let date = Date.now() - data.leaveDate; 22 | let member = guild.members.cache.get(data.memberID); 23 | if (!member) return await privateVoiceDatabase.deleteOne({ memberID: data.memberID }); 24 | if (date > 1000 * 60 * 5) { //5 dakika = 300.000 == 1000 * 60 * 5 25 | if (member.voice.channel && member.voice.channel.id == data.channelID) return; 26 | let channel = { v: guild.channels.cache.get(data.vchannelID), t: guild.channels.cache.get(data.tchannelID) } 27 | await privateVoiceDatabase.deleteOne({ memberID: data.memberID }); 28 | await channel.v.delete().catch(() => { }); 29 | await channel.t.delete().catch(() => { }); 30 | if (client.findChannel(channels.private.log)) client.findChannel(channels.private.log).send({ content: `${member}, özel odasına 5 dakikadır giriş yapmadığı için odası silindi.` }); 31 | } 32 | }, i * 550); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /src/commands/gir.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require("@discordjs/builders"); 2 | 3 | const privateVoiceDatabase = require('../models/privatevoice'); 4 | 5 | module.exports = { 6 | data: new SlashCommandBuilder() 7 | .setName('gir') 8 | .setDescription('Belirtilen kişinin kanalı bulunuyorsa ve şifresi bulunuyorsa odasına giriş izni verir.') 9 | .addUserOption(option => option.setName("üye").setDescription("Özel odasına giriş yapmak istediğiniz kişiyi belirtiniz.").setRequired(true)) 10 | .addStringOption(option => option.setName("şifre").setDescription("Odasına giriş yapmak istediğiniz kullanıcının oda şifresi.").setRequired(true)), 11 | run: async (interaction) => { 12 | const member = interaction.options.getUser('üye') 13 | const password = interaction.options.getString('şifre'); 14 | 15 | let privateVoiceData = await privateVoiceDatabase.findOne({ memberID: member.id }); 16 | if (!privateVoiceData) return interaction.reply({ content: `Bu kullanıcının özel odası bulunmuyor.`, ephemeral: true }); 17 | if (privateVoiceData?.password && privateVoiceData?.password == password) { 18 | let channel = { v: interaction.guild.channels.cache.get(privateVoiceData.vchannelID), t: interaction.guild.channels.cache.get(privateVoiceData.tchannelID) } 19 | if (!channel.v || !channel.t) { 20 | await privateVoiceDatabase.deleteOne({ memberID: member.id }); 21 | interaction.reply({ content: `Bu kişinin girebileceğiniz bir odası mevcut değil.`, ephemeral: true }) 22 | } else { 23 | await channel.v.permissionOverwrites.edit(interaction.member.id, { CONNECT: true }).catch(() => { }) 24 | await channel.t.permissionOverwrites.edit(interaction.member.id, { VIEW_CHANNEL: true, SEND_MESSAGES: true }).catch(() => { }) 25 | interaction.reply({ content: `${member}, adlı kişinin **${channel.v}/${channel.t}** ismine sahip odasına giriş/görüntüleme izni kazandın.`, ephemeral: true }) 26 | } 27 | } else { 28 | interaction.reply({ content: `Bu odanın şifresi yok veya yanlış şifre girdin.`, ephemeral: true }); 29 | } 30 | }, 31 | }; 32 | -------------------------------------------------------------------------------- /src/events/button.js: -------------------------------------------------------------------------------- 1 | const Modal = require('../functions/Modal'); 2 | const privateVoiceDatabase = require('../models/privatevoice'); 3 | 4 | module.exports = { 5 | event: "interactionCreate", 6 | oneTime: false, 7 | ws: false, 8 | run: async (interaction) => { 9 | if (interaction.isButton()) { 10 | let ids = ["btnKanaliSil","btnKullaniciEkle","btnKullaniciKaldir"]; 11 | if(!ids.includes(interaction.customId)) return; 12 | let guild = client.guilds.cache.get(settings.guild.id); 13 | let member = await guild.members.cache.get(interaction.member.user.id); 14 | let privateVoiceData = await privateVoiceDatabase.findOne({ memberID: member.id }); 15 | if (!privateVoiceData) return; 16 | if(privateVoiceData?.tchannelID != interaction.channel.id) return interaction.reply({content: `Özel oda sana ait değil!`, ephemeral: true}); 17 | if (interaction.customId == "btnKullaniciEkle") { 18 | const text = [{ 19 | type: 1, 20 | components: [ 21 | { 22 | type: 4, 23 | custom_id: 'kullaniciEkle', 24 | label: 'Kullanıcı id', 25 | placeholder: 'Kullanıcı id giriniz', 26 | style: 1, 27 | required: true 28 | }, 29 | ], 30 | },] 31 | new Modal(interaction, "Kullanıcı ekle", "kullaniciEkle", text); 32 | } else if (interaction.customId == "btnKullaniciKaldir") { 33 | const text = [{ 34 | type: 1, 35 | components: [ 36 | { 37 | type: 4, 38 | custom_id: 'kullaniciKaldir', 39 | label: 'Kullanıcı id', 40 | placeholder: 'Kullanıcı id giriniz', 41 | style: 1, 42 | required: true 43 | }, 44 | ], 45 | },] 46 | new Modal(interaction, "Kullanıcı kaldır", "kullaniciKaldir", text); 47 | } else if (interaction.customId == "btnKanaliSil") { 48 | let channel = { v: guild.channels.cache.get(privateVoiceData.vchannelID), t: guild.channels.cache.get(privateVoiceData.tchannelID) } 49 | interaction.reply({ content: `Odanız **3** saniye içerisinde silinecektir.`, ephemeral: true }).then(() => { 50 | setTimeout(async () => { 51 | await privateVoiceDatabase.deleteOne({ memberID: member.id }); 52 | await channel.v.delete().catch(() => { }); 53 | await channel.t.delete().catch(() => { }); 54 | }, 3000) 55 | if (client.findChannel(channels.private.log)) client.findChannel(channels.private.log).send({ content: `${member}, oluşturduğu özel odasını sildi.` }); 56 | }) 57 | } 58 | } 59 | }, 60 | }; -------------------------------------------------------------------------------- /src/commands/özelOda.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder } = require("@discordjs/builders"); 2 | const Modal = require('../functions/Modal'); 3 | 4 | const privateVoiceDatabase = require('../models/privatevoice'); 5 | 6 | module.exports = { 7 | data: new SlashCommandBuilder() 8 | .setName('özeloda') 9 | .setDescription('Özel oda oluşturmanızı sağlar. Eğer ki odanız varsa düzenleyebilirsiniz.') 10 | .addStringOption(option => 11 | option.setName('tip') 12 | .setDescription('Özel odalar hakkında ne yapacağınızı belirtiniz.') 13 | .setRequired(true) 14 | .addChoice('Oluştur', 'olustur') 15 | .addChoice('Sil', 'sil') 16 | .addChoice('Düzenle', 'duzenle')), 17 | run: async (interaction) => { 18 | const type = interaction.options.getString("tip") 19 | let privateVoiceData = await privateVoiceDatabase.findOne({ memberID: interaction.member.id }); 20 | if (type == "olustur") { 21 | if (privateVoiceData || privateVoiceData?.channelID) return interaction.reply({ content: `Yeni oda oluşturabilmek için önceki odanı silmelisin.`, ephemeral: true }); 22 | const text = [ 23 | { 24 | type: 1, 25 | components: [ 26 | { 27 | type: 4, 28 | custom_id: 'odaIsmi', 29 | label: 'Oda isminiz', 30 | placeholder: '(4-28) karakter', 31 | style: 1, 32 | min_length: 4, 33 | max_length: 28, 34 | required: true 35 | }, 36 | ], 37 | }, 38 | { 39 | type: 1, 40 | components: [ 41 | { 42 | type: 4, 43 | custom_id: 'odaPass', 44 | label: 'Oda şifreniz', 45 | placeholder: '(4-28) karakter', 46 | style: 1, 47 | min_length: 4, 48 | max_length: 28, 49 | required: false 50 | }, 51 | ], 52 | }, 53 | { 54 | type: 1, 55 | components: [ 56 | { 57 | type: 4, 58 | custom_id: 'odaLimit', 59 | label: 'Oda limitiniz', 60 | value: '0', 61 | placeholder: '(0-99) aralığında', 62 | style: 1, 63 | max_length: 2, 64 | required: false 65 | }, 66 | ], 67 | }, 68 | ] 69 | new Modal(interaction, "Oda oluştur", "odaOlustur", text); 70 | } else if (type == "sil") { 71 | if (!privateVoiceData) return interaction.reply({ content: `Silebileceğin her hangi bir özel oda bulunmuyor.`, ephemeral: true }); 72 | let channel = { v: guild.channels.cache.get(privateVoiceData.vchannelID), t: guild.channels.cache.get(privateVoiceData.tchannelID) } 73 | interaction.reply({ content: `Odanız **3** saniye içerisinde silinecektir.`, ephemeral: true }).then(async () => { 74 | setTimeout(async () => { 75 | await privateVoiceDatabase.deleteOne({ memberID: member.id }); 76 | await channel.v.delete().catch(() => { }); 77 | await channel.t.delete().catch(() => { }); 78 | }, 3000) 79 | if (client.findChannel(channels.private.log)) client.findChannel(channels.private.log).send({ content: `${member}, oluşturduğu özel odasını sildi.` }); 80 | }); 81 | } else if (type == "duzenle") { 82 | if (!privateVoiceData) return interaction.reply({ content: `Düzenleyebileceğin her hangi bir özel oda bulunmuyor.`, ephemeral: true }); 83 | let channel = {v: interaction.guild.channels.cache.get(privateVoiceData.vchannelID),t:interaction.guild.channels.cache.get(privateVoiceData.tchannelID)} 84 | const text = [ 85 | { 86 | type: 1, 87 | components: [ 88 | { 89 | type: 4, 90 | custom_id: 'odaIsmi', 91 | label: 'Oda isminiz', 92 | value: channel.v.name, 93 | placeholder: 'Yeni oda isminiz', 94 | style: 1, 95 | min_length: 4, 96 | max_length: 28, 97 | required: true 98 | }, 99 | ], 100 | }, 101 | { 102 | type: 1, 103 | components: [ 104 | { 105 | type: 4, 106 | custom_id: 'odaPass', 107 | label: 'Oda şifreniz', 108 | placeholder: 'Yeni oda şifreniz', 109 | style: 1, 110 | min_length: 4, 111 | max_length: 28, 112 | required: false 113 | }, 114 | ], 115 | }, 116 | { 117 | type: 1, 118 | components: [ 119 | { 120 | type: 4, 121 | custom_id: 'odaLimit', 122 | label: 'Oda limitiniz', 123 | value: channel.v.userLimit, 124 | placeholder: 'Yeni oda limitiniz (0-99)', 125 | style: 1, 126 | max_length: 2, 127 | required: false 128 | }, 129 | ], 130 | }, 131 | ] 132 | new Modal(interaction, "Oda düzenle", "odaDuzenle", text); 133 | } 134 | }, 135 | }; 136 | -------------------------------------------------------------------------------- /src/events/modal.js: -------------------------------------------------------------------------------- 1 | const { Permissions, MessageActionRow, MessageButton } = require('discord.js'); 2 | const privateVoiceDatabase = require('../models/privatevoice'); 3 | 4 | module.exports = { 5 | event: "INTERACTION_CREATE", 6 | ws: true, 7 | run: async (i) => { 8 | const ids = ['odaOlustur', 'odaDuzenle', 'odaSil', 'kullaniciKaldir', 'kullaniciEkle']; 9 | if (!ids.includes(i.data.custom_id)) return; 10 | let guild = client.guilds.cache.get(settings.guild.id); 11 | let everyone = guild.roles.everyone; 12 | let member = guild.members.cache.get(i.member.user.id); 13 | let text = `Bir sorun oluştu.`; 14 | let privateVoiceData = await privateVoiceDatabase.findOne({ memberID: member.id }); 15 | let channel; 16 | if (privateVoiceData) { 17 | channel = { v: guild.channels.cache.get(privateVoiceData.vchannelID), t: guild.channels.cache.get(privateVoiceData.tchannelID) } 18 | } 19 | if (i.data.custom_id == 'odaOlustur') { 20 | await guild.channels.create(`${i.data.components[0].components[0].value}`, { 21 | userLimit: i.data.components[2].components[0].value || 0, 22 | type: 'GUILD_TEXT', 23 | parent: channels.private.tparent, 24 | permissionOverwrites: [ 25 | { 26 | id: everyone.id, 27 | deny: [Permissions.FLAGS.VIEW_CHANNEL], 28 | }, 29 | { 30 | id: member.id, 31 | allow: [Permissions.FLAGS.VIEW_CHANNEL, Permissions.FLAGS.SEND_MESSAGES] 32 | }, 33 | ] 34 | }).then(async (tchn) => { 35 | await guild.channels.create(`${i.data.components[0].components[0].value}`, { 36 | userLimit: i.data.components[2].components[0].value || 0, 37 | type: 'GUILD_VOICE', 38 | parent: channels.private.vparent, 39 | permissionOverwrites: [ 40 | { 41 | id: everyone.id, 42 | deny: [Permissions.FLAGS.CONNECT], 43 | }, 44 | { 45 | id: member.id, 46 | allow: [Permissions.FLAGS.CONNECT, Permissions.FLAGS.MUTE_MEMBERS, Permissions.FLAGS.DEAFEN_MEMBERS, Permissions.FLAGS.STREAM] 47 | }, 48 | ] 49 | }).then(async (vchn) => { 50 | new privateVoiceDatabase({ 51 | memberID: member.id, 52 | tchannelID: tchn.id, 53 | vchannelID: vchn.id, 54 | password: i.data.components[1].components[0].value 55 | }).save(); 56 | let row = new MessageActionRow() 57 | .addComponents( 58 | new MessageButton() 59 | .setLabel("Kullanıcı ekle") 60 | .setStyle("SECONDARY") 61 | .setCustomId("btnKullaniciEkle"), 62 | new MessageButton() 63 | .setLabel("Kullanıcı kaldır") 64 | .setStyle("SECONDARY") 65 | .setCustomId("btnKullaniciKaldir"), 66 | new MessageButton() 67 | .setLabel("Kanalı sil") 68 | .setStyle("DANGER") 69 | .setCustomId("btnKanaliSil") 70 | ) 71 | tchn.send({ content: `Aşağıdaki düğmeler ile odanı yönetebilirsin.`, components: [row] }) 72 | if (client.findChannel(channels.private.log)) client.findChannel(channels.private.log).send({ content: `${member}, **${i.data.components[0].components[0].value}** isminde sesli özel oda oluşturdu.` }); 73 | text = `**${i.data.components[0].components[0].value}** isminde odanız başarıyla oluşturuldu.`; 74 | }) 75 | }) 76 | } else if (i.data.custom_id == 'odaDuzenle') { 77 | if (!channel.v || !channel.t) { 78 | await channel.v.delete().catch(() => { }); 79 | await channel.t.delete().catch(() => { }); 80 | await privateVoiceDatabase.deleteOne({ memberID: member.id }); 81 | return text = `Odanız bulunamadığı için oda veriniz silindi.`; 82 | } 83 | let degisiklikler = [] 84 | i.data.components.map(async (x, i) => { 85 | if (x.components[0].custom_id == 'odaIsmi' && (x.components[0].value != channel.v.name)) { 86 | let newObje = { 87 | olay: "Oda ismi", 88 | eskiVeri: channel.v.name, 89 | yeniVeri: x.components[0].value, 90 | }; 91 | degisiklikler.push(newObje); 92 | setTimeout(async () => { 93 | await channel.v.edit({ name: x.components[0].value }); 94 | //await channel.t.edit({ name: x.components[0].value }); Buna gerek yok istiyosan ekle 95 | }, i * 500) 96 | } else if (x.components[0].custom_id == 'odaPass' && (x.components[0].value != privateVoiceData.password)) { 97 | //if (!privateVoiceData.password || !x.components[0].value && (x.components[0].value.slice.join(' ').length < 0)) return; 98 | //niye üst taraf acik degil 99 | //burada niye böyle bir yazi var 100 | let newObje = { 101 | olay: "Oda şifresi", 102 | eskiVeri: privateVoiceData.password, 103 | yeniVeri: x.components[0].value || null 104 | }; 105 | degisiklikler.push(newObje); 106 | privateVoiceData.password = x.components[0].value || null; 107 | await privateVoiceData.save(); 108 | } else if (x.components[0].custom_id == 'odaLimit' && (x.components[0].value != channel.v.userLimit)) { 109 | if (!isNaN(x.components[0].value)) return; 110 | let newObje = { 111 | olay: "Oda limiti", 112 | eskiVeri: channel.v.userLimit, 113 | yeniVeri: x.components[0].value || 0, 114 | }; 115 | degisiklikler.push(newObje); 116 | setTimeout(async () => { 117 | await channel.v.edit({ userLimit: x.components[0].value || 0 }) 118 | }, i * 500) 119 | } 120 | }) 121 | text = `Odanız başarıyla düzenlendi. Yapılan değişiklikler;\n\n${degisiklikler.length > 0 ? degisiklikler.map(x => `**${x.olay};**\n• Eski veri: \`${x.eskiVeri || "yok"}\`\n• Yeni veri: \`${x.yeniVeri || "yok"}\``).join('\n─────────────────\n') : `Her hangi bir değişiklik yapılmadı.`}`; 122 | } else if (i.data.custom_id == 'kullaniciEkle') { 123 | let member = guild.members.cache.get(i.data.components[0].components[0].value); 124 | if (!member) return text = `Böyle bir kullanıcı bulunamadı`; 125 | await channel.v.permissionOverwrites.edit(member.id, { CONNECT: true }).catch(() => { }) 126 | await channel.t.permissionOverwrites.edit(member.id, { VIEW_CHANNEL: true, SEND_MESSAGES: true }).catch(() => { }) 127 | text = `${member} adlı kişiye özel odanıza giriş/görme izni verildi.`; 128 | } else if (i.data.custom_id == 'kullaniciKaldir') { 129 | let member = guild.members.cache.get(i.data.components[0].components[0].value); 130 | if (!member) return text = `Böyle bir kullanıcı bulunamadı`; 131 | await channel.v.permissionOverwrites.delete(member.id).catch(() => { }); 132 | await channel.t.permissionOverwrites.delete(member.id).catch(() => { }); 133 | text = `${member} adlı kişiye verdiğiniz izin kaldırıldı.`; 134 | } 135 | client.api.interactions(i.id, i.token).callback.post({ 136 | data: { 137 | type: 4, 138 | data: { 139 | content: text, 140 | flags: "64" 141 | } 142 | } 143 | }) 144 | } 145 | } 146 | --------------------------------------------------------------------------------