From 707d30a1264203b8dce4473b830706ed83dd5fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8B=E1=B4=80=CA=99=C9=AA=CA=80=E3=80=85=EA=9C=B1?= =?UTF-8?q?=C9=AA=C9=B4=C9=A2=CA=9C?= <73753258+kabirsingh2004@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:22:45 +0530 Subject: [PATCH] Delete events directory --- events/interactionCreate.js | 71 ------------------------------------- events/messageCreate.js | 63 -------------------------------- events/ready.js | 9 ----- 3 files changed, 143 deletions(-) delete mode 100644 events/interactionCreate.js delete mode 100644 events/messageCreate.js delete mode 100644 events/ready.js diff --git a/events/interactionCreate.js b/events/interactionCreate.js deleted file mode 100644 index d89e703..0000000 --- a/events/interactionCreate.js +++ /dev/null @@ -1,71 +0,0 @@ -const { - ApplicationCommandOptionType, - PermissionFlagsBits, -} = require("discord.js"); -const client = require(".."); -const { cooldown, getKeyByValue } = require("../handlers/functions"); -const { emoji } = require("../settings/config"); - -client.on("interactionCreate", async (interaction) => { - // Slash Command Handling - if (interaction.isChatInputCommand()) { - await interaction.deferReply().catch((e) => {}); - const cmd = client.commands.get(interaction.commandName); - if (!cmd) - return client.sendEmbed( - interaction, - `${emoji.ERROR} \`${interaction.commandName}\` Command Not Found ` - ); - const args = []; - for (let option of interaction.options.data) { - if (option.type === ApplicationCommandOptionType.Subcommand) { - if (option.name) args.push(option.name); - option.options?.forEach((x) => { - if (x.value) args.push(x.value); - }); - } else if (option.value) args.push(option.value); - } - interaction.member = interaction.guild.members.cache.get( - interaction.user.id - ); - if (cmd) { - // checking user perms - if (!interaction.member.permissions.has(cmd.userPermissions || [])) { - return client.sendEmbed( - interaction, - `You Don't Have \`${getKeyByValue( - PermissionFlagsBits, - cmd.userPermissions - )}\` Permission to Use \`${cmd.name}\` Command!!` - ); - } else if ( - !interaction.guild.members.me.permissions.has(cmd.botPermissions || []) - ) { - return client.sendEmbed( - interaction, - `I Don't Have \`${getKeyByValue( - PermissionFlagsBits, - cmd.botPermissions - )}\` Permission to Use \`${cmd.name}\` Command!!` - ); - } else if (cooldown(interaction, cmd)) { - return client.sendEmbed( - interaction, - ` You are On Cooldown , wait \`${cooldown( - interaction, - cmd - ).toFixed()}\` Seconds` - ); - } else { - cmd.run(client, interaction, args); - } - } - } - - // Context Menu Handling - if (interaction.isContextMenuCommand()) { - await interaction.deferReply({ ephemeral: true }).catch((e) => {}); - const command = client.commands.get(interaction.commandName); - if (command) command.run(client, interaction); - } -}); diff --git a/events/messageCreate.js b/events/messageCreate.js deleted file mode 100644 index 6e048c5..0000000 --- a/events/messageCreate.js +++ /dev/null @@ -1,63 +0,0 @@ -const { cooldown, getKeyByValue } = require("../handlers/functions"); -const client = require(".."); -const { prefix: botPrefix, emoji } = require("../settings/config"); -const { PermissionFlagsBits } = require("discord.js"); - -client.on("messageCreate", async (message) => { - if (message.author.bot || !message.guild || !message.id) return; - let prefix = botPrefix; - let mentionprefix = new RegExp( - `^(<@!?${client.user.id}>|${escapeRegex(prefix)})\\s*` - ); - if (!mentionprefix.test(message.content)) return; - const [, nprefix] = message.content.match(mentionprefix); - const args = message.content.slice(nprefix.length).trim().split(/ +/); - const cmd = args.shift().toLowerCase(); - if (cmd.length === 0) { - if (nprefix.includes(client.user.id)) { - client.sendEmbed( - message, - ` ${emoji.SUCCESS} To See My All Commands Type \`/help\` or \`${prefix}help\`` - ); - } - } - const command = - client.mcommands.get(cmd) || - client.mcommands.find((cmds) => cmds.aliases && cmds.aliases.includes(cmd)); - if (!command) return; - if (command) { - if (!message.member.permissions.has(command.userPermissions || null)) { - return client.sendEmbed( - message, - `${emoji.ERROR} You must have the \`${getKeyByValue( - PermissionFlagsBits, - command.userPermissions - )}\` permission to use \`${command.name}\` command!` - ); - } else if ( - !message.guild.members.me.permissions.has(command.botPermissions || null) - ) { - return client.sendEmbed( - message, - `${emoji.ERROR} I must have the \`${getKeyByValue( - PermissionFlagsBits, - command.botPermissions - )}\` permission to use \`${command.name}\` command!` - ); - } else if (cooldown(message, command)) { - return client.sendEmbed( - message, - `*You are On Cooldown , wait \`${cooldown( - message, - command - ).toFixed()}\` Seconds*` - ); - } else { - command.run(client, message, args, nprefix); - } - } -}); - -function escapeRegex(newprefix) { - return newprefix.replace(/[.*+?^${}()|[\]\\]/g, `\\$&`); -} diff --git a/events/ready.js b/events/ready.js deleted file mode 100644 index 14cbfbd..0000000 --- a/events/ready.js +++ /dev/null @@ -1,9 +0,0 @@ -const client = require("../index"); - -client.on("ready", async () => { - console.log(`${client.user.username} Is Online`); - client.user.setActivity({ - name: `@${client.user.username} /help`, - type: "PLAYING", - }); -});