mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 06:28:53 +00:00
Added system command support
This commit is contained in:
1 parent
9feff8c62f
commit
64543752ae
1 file changed
+11
-3
@@ -1,7 +1,7 @@
|
||||
const fs = require('node:fs');
|
||||
const Discord = require('discord.js');
|
||||
const { Player } = require('discord-player');
|
||||
const { token } = require('./config.json');
|
||||
const { token, embedColors } = require('./config.json');
|
||||
|
||||
// Setup required permissions for the bot to work
|
||||
const client = new Discord.Client({
|
||||
@@ -21,6 +21,14 @@ for (const file of commandFiles) {
|
||||
client.commands.set(command.data.name, command);
|
||||
}
|
||||
|
||||
const systemCommandFiles = fs
|
||||
.readdirSync('./system-commands')
|
||||
.filter((file) => file.endsWith('.js'));
|
||||
for (const file of systemCommandFiles) {
|
||||
const systemCommand = require(`./system-commands/${file}`);
|
||||
client.commands.set(systemCommand.data.name, systemCommand);
|
||||
}
|
||||
|
||||
// Create a new Player, and attach it to the bot client.
|
||||
const player = new Player(client, {
|
||||
ytdlOptions: {
|
||||
@@ -83,7 +91,7 @@ client.on('interactionCreate', async (interaction) => {
|
||||
|
||||
try {
|
||||
await interaction.deferReply();
|
||||
await command.run({ interaction });
|
||||
await command.run({ interaction, client });
|
||||
console.log(
|
||||
`Command '/${interaction.commandName}' was executed successfully.`
|
||||
);
|
||||
@@ -99,7 +107,7 @@ client.on('interactionCreate', async (interaction) => {
|
||||
.setDescription(
|
||||
`**Error**\nThere was an error while executing this command!\n\nIf this issue persists, please submit an issue in the support server: https://discord.gg/t6Bm8wPpXB`
|
||||
)
|
||||
.setColor('#c70057')
|
||||
.setColor(embedColors.colorError)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user