From 00a6a967b07ab46dfec19ae67a727b07494826f7 Mon Sep 17 00:00:00 2001 From: -`Ashborn <77638593+Jarvis1337@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:46:42 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Added=20Permission=20Handler=20i?= =?UTF-8?q?n=20XversE=20<3!..=20-=20Update=20index.js=20-=20Update=20messa?= =?UTF-8?q?geCreate.js=20-=20Update=20interactionCreate.js=20-=20Update=20?= =?UTF-8?q?config.js=20-=20Update=20ping.js=20-=20Message=20&=20Slash=20Bo?= =?UTF-8?q?th=20Commands=20<3!..=20-=20Update=20version.js=20-=20Message?= =?UTF-8?q?=20&=20Slash=20Both=20Commands=20<3!..=20-=20Update=20package.j?= =?UTF-8?q?son=20-=20Update=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Commands/Message/Mics/ping.js | 2 ++ Commands/Message/Mics/version.js | 2 ++ Commands/Slash/Mics/ping.js | 2 ++ Commands/Slash/Mics/version.js | 2 ++ README.md | 6 +++++- events/interactionCreate.js | 10 +++++++++- events/messageCreate.js | 11 +++++++++-- index.js | 2 +- package.json | 5 +++-- settings/config.js | 2 +- 10 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Commands/Message/Mics/ping.js b/Commands/Message/Mics/ping.js index 51542ec..af952cc 100644 --- a/Commands/Message/Mics/ping.js +++ b/Commands/Message/Mics/ping.js @@ -5,6 +5,8 @@ module.exports = { name: "ping", aliases: ["latancy"], description: "Get the Ping for XversE in your Server!", + userPermissions: 'SEND_MESSAGES', + botPermissions: 'EMBED_LINKS', cooldown: 10, /** diff --git a/Commands/Message/Mics/version.js b/Commands/Message/Mics/version.js index 13bbe6a..6680f83 100644 --- a/Commands/Message/Mics/version.js +++ b/Commands/Message/Mics/version.js @@ -6,6 +6,8 @@ module.exports = { name: "version", aliases: ["ver"], description: "Check the current version of XversE-Adv-Handler", + userPermissions: 'SEND_MESSAGES', + botPermissions: 'EMBED_LINKS', cooldown: 10, /** diff --git a/Commands/Slash/Mics/ping.js b/Commands/Slash/Mics/ping.js index d04c6fc..62926ca 100644 --- a/Commands/Slash/Mics/ping.js +++ b/Commands/Slash/Mics/ping.js @@ -4,6 +4,8 @@ const Jarvisx1337 = require("../../../index"); module.exports = { name: "ping", description: "Get the Ping for XversE in your Server!", + userPermissions: 'SEND_MESSAGES', + botPermissions: 'EMBED_LINKS', cooldown: 10, type: "CHAT_INPUT", diff --git a/Commands/Slash/Mics/version.js b/Commands/Slash/Mics/version.js index 1737d0a..503caaa 100644 --- a/Commands/Slash/Mics/version.js +++ b/Commands/Slash/Mics/version.js @@ -5,6 +5,8 @@ const config = require("../../../settings/config.js"); module.exports = { name: "version", description: "Check the current version of XversE-Adv-Handler", + userPermissions: 'SEND_MESSAGES', + botPermissions: 'EMBED_LINKS', cooldown: 10, type: "CHAT_INPUT", diff --git a/README.md b/README.md index f4ec6b8..2952255 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ TOKEN : process.env.TOKEN || "", "PREFIX" : process.env.PREFIX || "..", "XversE" : { - "version" : "2.1.0", + "version" : "2.1.2", "logChannelID" : process.env.logChannelID || "Logging-Channel-ID" } } @@ -91,6 +91,8 @@ module.exports = { name: "", aliases: [""], description: "", + userPermissions: '', + botPermissions: '', cooldown: 10, /** @@ -116,6 +118,8 @@ const Jarvisx1337 = require("../../../index"); module.exports = { name: "", description: "", + userPermissions: '', + botPermissions: '', cooldown: 10, type: "CHAT_INPUT", diff --git a/events/interactionCreate.js b/events/interactionCreate.js index d1ad2a4..f0e40c9 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -1,3 +1,4 @@ +const { Permissions } = require("discord.js"); const client = require("../index"); const { Cooldown } = require("../handlers/functions") const config = require("../settings/config") @@ -24,8 +25,15 @@ client.on("interactionCreate", async (interaction) => { ); if (cmd) { + // + if (!interaction.member.permissions.has(Permissions.FLAGS[cmd.userPermissions] || [])) { + return interaction.followUp(`${config.Emoji.Error} ${interaction.user.username} You don't have \`${cmd.userPermissions}\`, Permission to use this \`${cmd.name}\` command...`) + } else if (!interaction.guild.members.me.permissions.has(Permissions.FLAGS[cmd.botPermissions] || [])) { + return interaction.followUp(`${config.Emoji.Error} I don't have \`${cmd.botPermissions}\`, Permission to Execute this \`${cmd.name}\` command...`) + } + if (Cooldown(interaction, cmd)) { - interaction.followUp(`${config.Emoji.Error} ${interaction.user.username} You are on Cooldown, So Please wait Until \`${Cooldown(interaction, cmd).toFixed()}\` seconds...`) + return interaction.followUp(`${config.Emoji.Error} ${interaction.user.username} You are on Cooldown, So Please wait Until \`${Cooldown(interaction, cmd).toFixed()}\` seconds...`) } else { cmd.Xexecute(client, interaction, args); } diff --git a/events/messageCreate.js b/events/messageCreate.js index a9cb5eb..1d96513 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -1,4 +1,4 @@ -const { MessageEmbed, MessageActionRow, MessageButton } = require("discord.js"); +const { MessageEmbed, MessageActionRow, MessageButton, Permissions } = require("discord.js"); const client = require("../index"); const { Cooldown } = require("../handlers/functions") const { PREFIX } = require("../settings/config"); @@ -71,8 +71,15 @@ client.on("messageCreate", async (message) => { client.commands.find((cmds) => cmds.aliases && cmds.aliases.includes(cmd)); if (!command) return; if (command) { + // + if (!message.member.permissions.has(Permissions.FLAGS[command.userPermissions] || [])) { + return message.channel.send(`${config.Emoji.Error} ${message.author.username} You don't have \`${command.userPermissions}\`, Permission to use this \`${command.name}\` command...`) + } else if (!message.guild.members.me.permissions.has(Permissions.FLAGS[command.botPermissions] || [])) { + return message.channel.send(`${config.Emoji.Error} I don't have \`${command.botPermissions}\`, Permission to Execute this \`${command.name}\` command...`) + } + if (Cooldown(message, command)) { - message.channel.send(`${config.Emoji.Error} ${message.author.username} You are on Cooldown, So Please wait Until \`${Cooldown(message, command).toFixed()}\` seconds...`) + return message.channel.send(`${config.Emoji.Error} ${message.author.username} You are on Cooldown, So Please wait Until \`${Cooldown(message, command).toFixed()}\` seconds...`) } else { command.Xexecute(client, message, args, nprefix); } diff --git a/index.js b/index.js index 87f47e6..3dea6f8 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ const fs = require("fs"); const config = require("./settings/config.js"); const client = new Client({ - intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES], + intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS], partials: ["GUILD", "GUILD_MEMBER", "CHANNEL", "MESSAGE", "USER"], messageCacheLifetime: 60, fetchAllMembers: false, diff --git a/package.json b/package.json index a010ba8..66e5611 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "Xverse-Adv-Handler", - "version": "2.1.1", + "version": "2.1.2", "description": "XversE-Adv-Handler is a Discord.js v13 handler with advanced features. With features such as a premium system, MongoDB connectivity, and advanced developer commands, it provides the foundation for powerful bots. Take your Discord bots to the next level by streamlining your development process <3...", "main": "index.js", "scripts": { "start": "node index.js", "node": "npm i --save-dev node@latest && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH" }, - "author": ["Jarvis1337", "Yours-Jarvis"], + "author": "Jarvis1337", + "maintainers": ["Jarvis1337", "X-Nova1337", "X-Kaisel", "y3rawat"], "keywords": [ "discord.js", "discord-bot", diff --git a/settings/config.js b/settings/config.js index 97e3de8..169e437 100644 --- a/settings/config.js +++ b/settings/config.js @@ -4,7 +4,7 @@ module.exports = { PREFIX: process.env.PREFIX || "..", XversE: { - version: "2.1.1", + version: "2.1.2", logChannelID: process.env.logChannelID || "Logging-Channel-ID", DiscordServer: "https://discord.gg/Jarvis-HQ", Jarvis: "https://discord.com/users/899961311771897877",