From e5c86859e4c6a9a6829bcc2e3cf626b05a873ff7 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 20 Dec 2022 17:54:56 -0500 Subject: Revamped next/previous cmds (Voting system); Basic i18n support; --- bot.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'bot.js') diff --git a/bot.js b/bot.js index 53c5cb1..244f2d5 100644 --- a/bot.js +++ b/bot.js @@ -18,11 +18,11 @@ * along with this program. If not, see . * ***************************************************************************/ -import { Client, GatewayIntentBits, EmbedBuilder, Collection, version, InteractionType } from 'discord.js'; +import { Client, Events, GatewayIntentBits, EmbedBuilder, Collection, version, InteractionType } from 'discord.js'; import { voiceInit } from './AudioBackend/VoiceInitialization.js'; import { readdirSync, readFileSync } from 'node:fs'; // import config from './config.json' assert { type: 'json' } Not supported by ESLint yet -const { token, statusChannel, voiceChannel, shuffle, repeat, presenceActivity, activityType } = JSON.parse(readFileSync('./config.json', 'utf-8')); +const { token, statusChannel, voiceChannel, djRole, ownerID, shuffle, repeat, presenceActivity, activityType } = JSON.parse(readFileSync('./config.json', 'utf-8')); const bot = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates] }); bot.login(token); @@ -41,12 +41,14 @@ for (const file of commandFiles) { bot.commands.set(command.data.name, command); } -bot.once('ready', async() => { +bot.once(Events.ClientReady, async() => { console.log('Bot is ready!'); console.log(`Logged in as ${bot.user.tag}!`); console.log(`Running on Discord.JS ${version}`); console.log(`Voice Channel: ${voiceChannel}`); console.log(`Status Channel: ${statusChannel}`); + console.log(`DJ Role: ${djRole}`); + console.log(`Owner ID: ${ownerID}`); console.log(`Shuffle Enabled: ${shuffle}`); console.log(`Repeat Enabled: ${repeat}`); @@ -75,9 +77,9 @@ bot.once('ready', async() => { return await voiceInit(bot); }); -bot.on('interactionCreate', async interaction => { +bot.on(Events.InteractionCreate, async interaction => { if (interaction.type === !InteractionType.ApplicationCommand) return; - + if (!interaction.isChatInputCommand()) return; const command = bot.commands.get(interaction.commandName); if (!command) return; @@ -86,6 +88,6 @@ bot.on('interactionCreate', async interaction => { await command.execute(interaction, bot); } catch (e) { console.error(e); - await interaction.reply({ content: `There was an error while executing this command!\nShare this to the bot owner!\n\nDetails:\`\`\`${e}\`\`\``, ephemeral: true }); + await interaction.reply({ content: `There was an error while executing this command...\nShare this to the bot owner or report it to the git repository in \`/about\`\n\nDetails:\`\`\`${e}\`\`\``, ephemeral: true }); } }); -- cgit v1.2.3