From cf5151fcd7236ca2d86d95684289245c3a4a71cc Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Wed, 12 Jul 2023 20:34:54 +0200 Subject: [PATCH] feat: system commands are no longer restricted to bot owner id, and can be used in list of specified guilds --- config.json.example | 11 +++++++++-- deploy-system-commands.js | 16 +++++++++------- system-commands/guilds.js | 11 ++--------- system-commands/status.js | 11 ++--------- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/config.json.example b/config.json.example index 30d75d1..fc07a16 100644 --- a/config.json.example +++ b/config.json.example @@ -1,8 +1,7 @@ { "clientId": "Your bot Application ID here.", "token": "Your bot auth token here.", - "systemServerGuildId": "Your Discord Server ID for system commands here.", - "botOwnerClientId": "Your own Discord user ID to access system commands here.", + "systemServerGuildIds": ["Server id where system commands can be used", "Another server id where system commands can be used"], "embedColors": { "colorSuccess": "#23A55A", "colorWarning": "#F0B232", @@ -21,6 +20,14 @@ "maxQueueSize": 1000, "maxHistorySize": 100 }, + "progressBarOptions": { + "length": 10, + "timecodes": false, + "separator": "┃", + "indicator": "🔘", + "leftChar": "▬", + "rightChar": "▬" + }, "minimumLogLevel": "debug", "minimumLogLevelConsole": "info", "filterThreadAmount": "4", diff --git a/deploy-system-commands.js b/deploy-system-commands.js index e1ca917..e6940af 100644 --- a/deploy-system-commands.js +++ b/deploy-system-commands.js @@ -1,7 +1,7 @@ const fs = require('node:fs'); const logger = require('./services/logger.js'); const { REST, Routes } = require('discord.js'); -const { token, clientId, systemServerGuildId } = require('./config.json'); +const { token, clientId, systemServerGuildIds } = require('./config.json'); const systemCommands = []; const systemCommandFiles = fs @@ -27,12 +27,14 @@ const rest = new REST({ version: '10' }).setToken(token); logger.info('Started refreshing application (/) system commands.'); - await rest.put( - Routes.applicationGuildCommands(clientId, systemServerGuildId), - { - body: systemCommands - } - ); + for (const systemServerGuildId of systemServerGuildIds) { + await rest.put( + Routes.applicationGuildCommands(clientId, systemServerGuildId), + { + body: systemCommands + } + ); + } logger.info('Successfully refreshed application (/) system commands.'); } catch (error) { diff --git a/system-commands/guilds.js b/system-commands/guilds.js index 15b91a0..9059405 100644 --- a/system-commands/guilds.js +++ b/system-commands/guilds.js @@ -1,20 +1,13 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); const { EmbedBuilder } = require('discord.js'); -const { - embedColors, - systemServerGuildId, - botOwnerClientId -} = require('../config.json'); +const { embedColors, systemServerGuildIds } = require('../config.json'); module.exports = { data: new SlashCommandBuilder() .setName('guilds') .setDescription('Show list of guilds where bot is added.'), run: async ({ interaction, client }) => { - if ( - interaction.guildId !== systemServerGuildId || - interaction.user.id !== botOwnerClientId - ) { + if (!systemServerGuildIds.includes(interaction.guildId)) { return await interaction.editReply({ embeds: [ new EmbedBuilder() diff --git a/system-commands/status.js b/system-commands/status.js index 304bd3c..95b9577 100644 --- a/system-commands/status.js +++ b/system-commands/status.js @@ -1,21 +1,14 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); const { EmbedBuilder } = require('discord.js'); const { useQueue } = require('discord-player'); -const { - embedColors, - systemServerGuildId, - botOwnerClientId -} = require('../config.json'); +const { embedColors, systemServerGuildIds } = require('../config.json'); module.exports = { data: new SlashCommandBuilder() .setName('status') .setDescription('Show bot status.'), run: async ({ interaction, client }) => { - if ( - interaction.guildId !== systemServerGuildId || - interaction.user.id !== botOwnerClientId - ) { + if (!systemServerGuildIds.includes(interaction.guildId)) { return await interaction.editReply({ embeds: [ new EmbedBuilder()