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.",
"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",
+9 -7
View File
@@ -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) {
+2 -9
View File
@@ -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()
+2 -9
View File
@@ -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()