setrole as global command

This commit is contained in:
2023-06-17 00:14:39 +02:00
parent 5883d6d726
commit 266a94cf9e
2 changed files with 13 additions and 6 deletions
+5 -1
View File
@@ -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
+8 -5
View File
@@ -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