From 55f0a6d6245fe4ab6f9a43b0f133bdbf7a925a81 Mon Sep 17 00:00:00 2001 From: kaddaimohammad-art Date: Mon, 8 Jun 2026 19:23:35 +0100 Subject: [PATCH] Update index.js --- index.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/index.js b/index.js index 252369712..3dc4858de 100644 --- a/index.js +++ b/index.js @@ -1,2 +1,55 @@ import './src/app.js'; +const { Client, GatewayIntentBits, ChannelType } = require("discord.js"); +const { joinVoiceChannel } = require("@discordjs/voice"); +const client = new Client({ + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + ], +}); + +const PREFIX = "!"; + +client.on("ready", () => { + console.log(`Logged in as ${client.user.tag}`); +}); + +client.on("messageCreate", async (message) => { + if (message.author.bot) return; + if (!message.content.startsWith(PREFIX)) return; + + const args = message.content.slice(PREFIX.length).trim().split(/ +/); + const command = args.shift().toLowerCase(); + + // !join #voice-channel + if (command === "join") { + const channel = + message.mentions.channels.first() || + message.guild.channels.cache.get(args[0]); + + if (!channel) { + return message.reply("❌ لازم تمنشن روم فويس أو تعطي ID تاعه"); + } + + if (channel.type !== ChannelType.GuildVoice) { + return message.reply("❌ هذا مو روم فويس"); + } + + try { + joinVoiceChannel({ + channelId: channel.id, + guildId: message.guild.id, + adapterCreator: message.guild.voiceAdapterCreator, + }); + + message.reply(`✅ دخلت للروم: **${channel.name}**`); + } catch (err) { + console.error(err); + message.reply("❌ صار خطأ في الدخول للروم"); + } + } +}); + +client.login("MTQ1MDIyODExNjQ1MzU4OTA1NA.G3ZMPY.fHYCVHkMq898zgRXTUQAEiYh1r7eG1rBQfz_j4");