Discord Administrator Role Permissions (#54)

* add: admin check for disable

* update: shutoff uses memberPerms now

* rm: superUser env variable

* update: version increment

* rm: admin env in docker and workflow
This commit is contained in:
Kevin Dang
2024-04-25 11:26:22 -07:00
committed by GitHub
parent d67106c03e
commit b5194fa645
8 changed files with 20 additions and 21 deletions

View File

@@ -4,7 +4,7 @@ import { openFile } from '../utils/jsonHandler.js'
export const Disable: SlashCommand = {
name: 'toggle-chat',
description: 'toggle all chat features, slash commands will still work.',
description: 'toggle all chat features, Adminstrator Only.',
// set available user options to pass to the command
options: [
@@ -22,6 +22,15 @@ export const Disable: SlashCommand = {
const channel = await client.channels.fetch(interaction.channelId)
if (!channel || channel.type !== ChannelType.GuildText) return
// check if runner is an admin
if (!interaction.memberPermissions?.has('Administrator')) {
interaction.reply({
content: `${interaction.commandName} is an Administrator Command.\n\nYou, ${interaction.member?.user.username}, are not an Administrator in this server.\nPlease contact an admin to use this command.`,
ephemeral: true
})
return
}
// set state of bot chat features
openFile('config.json', interaction.commandName, interaction.options.get('enabled')?.value)