From 266a94cf9e58a8ae4d2a82ef8f3f8ce7a3d0e7b1 Mon Sep 17 00:00:00 2001 From: Legonzaur Date: Sat, 17 Jun 2023 00:14:39 +0200 Subject: [PATCH] setrole as global command --- src/commands/checkroles.ts | 6 +++++- src/commands/setrole.ts | 13 ++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/commands/checkroles.ts b/src/commands/checkroles.ts index 9d30118..93aa108 100644 --- a/src/commands/checkroles.ts +++ b/src/commands/checkroles.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder, EmbedBuilder, PermissionsBitField } from 'discord.js' import { execute, type PermsNumbers } from '../db' -import { owner_id } from '../config.json' +import { owner_id, discord_guild_id } from '../config.json' module.exports = { global: false, @@ -17,6 +17,10 @@ module.exports = { } if (interaction.user.id !== owner_id) { + if (interaction.guildId !== discord_guild_id) { + void interaction.reply({ content: 'I am sorry dave, I\'m afraid I cannot do that\nRole settings are only available in main guild', ephemeral: true }) + return + } if ((interaction.memberPermissions?.has(PermissionsBitField.Flags.ManageRoles, true)) !== true) { await interaction.reply({ content: 'I am sorry dave, I\'m afraid I cannot do that\nYou don\'t have the permission to manage roles on this server', ephemeral: true }) return diff --git a/src/commands/setrole.ts b/src/commands/setrole.ts index 37a9f72..ea95719 100644 --- a/src/commands/setrole.ts +++ b/src/commands/setrole.ts @@ -3,10 +3,10 @@ import { SlashCommandBuilder, PermissionsBitField } from 'discord.js' import { execute } from '../db' -import { discord_guild_id } from '../config.json' +import { discord_guild_id, owner_id } from '../config.json' module.exports = { - global: false, + global: true, data: new SlashCommandBuilder() .setName('setrole') .setDescription('Adds permissions to a discord role') @@ -39,10 +39,13 @@ module.exports = { void interaction.reply({ content: 'Cannot find role', ephemeral: true }) return } - if (interaction.guildId !== discord_guild_id) { - void interaction.reply({ content: 'I am sorry dave, I\'m afraid I cannot do that\nRole settings are only available in main guild', ephemeral: true }) - return + if (interaction.user.id !== owner_id) { + if (interaction.guildId !== discord_guild_id) { + void interaction.reply({ content: 'I am sorry dave, I\'m afraid I cannot do that\nRole settings are only available in main guild', ephemeral: true }) + return + } } + if ((interaction.memberPermissions?.has(PermissionsBitField.Flags.ManageRoles, true)) !== true) { void interaction.reply({ content: 'I am sorry dave, I\'m afraid I cannot do that\nYou don\'t have the permission to manage roles on this server', ephemeral: true }) return