Skip to content

Commit

Permalink
πŸš€ Added Permission Handler in XversE <3!..
Browse files Browse the repository at this point in the history
- Update index.js
- Update messageCreate.js
- Update interactionCreate.js
- Update config.js
- Update ping.js - Message & Slash Both Commands <3!..
- Update version.js - Message & Slash Both Commands <3!..
- Update package.json
- Update README.md
  • Loading branch information
Jarvis1337 authored Oct 9, 2024
1 parent 9cb87e9 commit 00a6a96
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Commands/Message/Mics/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

/**
Expand Down
2 changes: 2 additions & 0 deletions Commands/Message/Mics/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

/**
Expand Down
2 changes: 2 additions & 0 deletions Commands/Slash/Mics/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
2 changes: 2 additions & 0 deletions Commands/Slash/Mics/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down Expand Up @@ -91,6 +91,8 @@ module.exports = {
name: "",
aliases: [""],
description: "",
userPermissions: '',
botPermissions: '',
cooldown: 10,
/**
Expand All @@ -116,6 +118,8 @@ const Jarvisx1337 = require("../../../index");
module.exports = {
name: "",
description: "",
userPermissions: '',
botPermissions: '',
cooldown: 10,
type: "CHAT_INPUT",
Expand Down
10 changes: 9 additions & 1 deletion events/interactionCreate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { Permissions } = require("discord.js");
const client = require("../index");
const { Cooldown } = require("../handlers/functions")
const config = require("../settings/config")
Expand All @@ -24,8 +25,15 @@ client.on("interactionCreate", async (interaction) => {
);

if (cmd) {
// <!--- Permission Handler--->
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);
}
Expand Down
11 changes: 9 additions & 2 deletions events/messageCreate.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -71,8 +71,15 @@ client.on("messageCreate", async (message) => {
client.commands.find((cmds) => cmds.aliases && cmds.aliases.includes(cmd));
if (!command) return;
if (command) {
// <!--- Permission Handler--->
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);
}
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion settings/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 00a6a96

Please sign in to comment.