feat: system commands are no longer restricted to bot owner id, and can be used in list of specified guilds

This commit is contained in:
Marius Begby committed 2023-07-12 20:34:54 +02:00
1 parent 1d7d810421
commit cf5151fcd7
4 files changed
+22 -27

No files matched your search

+9 -2
View File
@@ -1,8 +1,7 @@
{ {
"clientId": "Your bot Application ID here.", "clientId": "Your bot Application ID here.",
"token": "Your bot auth token here.", "token": "Your bot auth token here.",
"systemServerGuildId": "Your Discord Server ID for system commands here.", "systemServerGuildIds": ["Server id where system commands can be used", "Another server id where system commands can be used"],
"botOwnerClientId": "Your own Discord user ID to access system commands here.",
"embedColors": { "embedColors": {
"colorSuccess": "#23A55A", "colorSuccess": "#23A55A",
"colorWarning": "#F0B232", "colorWarning": "#F0B232",
@@ -21,6 +20,14 @@
"maxQueueSize": 1000, "maxQueueSize": 1000,
"maxHistorySize": 100 "maxHistorySize": 100
}, },
"progressBarOptions": {
"length": 10,
"timecodes": false,
"separator": "┃",
"indicator": "🔘",
"leftChar": "▬",
"rightChar": "▬"
},
"minimumLogLevel": "debug", "minimumLogLevel": "debug",
"minimumLogLevelConsole": "info", "minimumLogLevelConsole": "info",
"filterThreadAmount": "4", "filterThreadAmount": "4",
+9 -7
View File
@@ -1,7 +1,7 @@
const fs = require('node:fs'); const fs = require('node:fs');
const logger = require('./services/logger.js'); const logger = require('./services/logger.js');
const { REST, Routes } = require('discord.js'); const { REST, Routes } = require('discord.js');
const { token, clientId, systemServerGuildId } = require('./config.json'); const { token, clientId, systemServerGuildIds } = require('./config.json');
const systemCommands = []; const systemCommands = [];
const systemCommandFiles = fs const systemCommandFiles = fs
@@ -27,12 +27,14 @@ const rest = new REST({ version: '10' }).setToken(token);
logger.info('Started refreshing application (/) system commands.'); logger.info('Started refreshing application (/) system commands.');
await rest.put( for (const systemServerGuildId of systemServerGuildIds) {
Routes.applicationGuildCommands(clientId, systemServerGuildId), await rest.put(
{ Routes.applicationGuildCommands(clientId, systemServerGuildId),
body: systemCommands {
} body: systemCommands
); }
);
}
logger.info('Successfully refreshed application (/) system commands.'); logger.info('Successfully refreshed application (/) system commands.');
} catch (error) { } catch (error) {
+2 -9
View File
@@ -1,20 +1,13 @@
const { SlashCommandBuilder } = require('@discordjs/builders'); const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js'); const { EmbedBuilder } = require('discord.js');
const { const { embedColors, systemServerGuildIds } = require('../config.json');
embedColors,
systemServerGuildId,
botOwnerClientId
} = require('../config.json');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('guilds') .setName('guilds')
.setDescription('Show list of guilds where bot is added.'), .setDescription('Show list of guilds where bot is added.'),
run: async ({ interaction, client }) => { run: async ({ interaction, client }) => {
if ( if (!systemServerGuildIds.includes(interaction.guildId)) {
interaction.guildId !== systemServerGuildId ||
interaction.user.id !== botOwnerClientId
) {
return await interaction.editReply({ return await interaction.editReply({
embeds: [ embeds: [
new EmbedBuilder() new EmbedBuilder()
+2 -9
View File
@@ -1,21 +1,14 @@
const { SlashCommandBuilder } = require('@discordjs/builders'); const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js'); const { EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player'); const { useQueue } = require('discord-player');
const { const { embedColors, systemServerGuildIds } = require('../config.json');
embedColors,
systemServerGuildId,
botOwnerClientId
} = require('../config.json');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('status') .setName('status')
.setDescription('Show bot status.'), .setDescription('Show bot status.'),
run: async ({ interaction, client }) => { run: async ({ interaction, client }) => {
if ( if (!systemServerGuildIds.includes(interaction.guildId)) {
interaction.guildId !== systemServerGuildId ||
interaction.user.id !== botOwnerClientId
) {
return await interaction.editReply({ return await interaction.editReply({
embeds: [ embeds: [
new EmbedBuilder() new EmbedBuilder()