From cf1382d88c5e3298923c8cb243b7bc5751e68b53 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 2 Mar 2025 22:27:57 -0500 Subject: Ported more commands; Made embed colour a const; Cleanup --- bot/src/events/ClientReady.js | 12 +++++++----- bot/src/events/InteractionCreate.js | 12 ++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'bot/src/events') diff --git a/bot/src/events/ClientReady.js b/bot/src/events/ClientReady.js index c3c6055..335a2ac 100644 --- a/bot/src/events/ClientReady.js +++ b/bot/src/events/ClientReady.js @@ -1,21 +1,23 @@ import { Events } from 'discord.js'; import { readFileSync } from 'node:fs'; -import { activities as activity } from '../storage/activities.js'; +import { activities } from '../storage/activities.js'; +const { version } = JSON.parse(readFileSync('./package.json', 'utf-8')); function botActivity(client) { + const activity = activities[Math.floor(Math.random() * activities.length)]; + client.user.setPresence({ activities: [{ - name: activity[Math.floor(Math.random() * activity.length)] + name: activity.name, + type: activity.type }], status: 'online', afk: false, }); - console.log(`[>] Updated bot presence to "${client.user.presence.activities[0].name}"`); + console.log(`[>] Updated bot presence to "${activity.name}"`); } -const { version } = JSON.parse(readFileSync('./package.json', 'utf-8')); - export default { name: Events.ClientReady, once: true, diff --git a/bot/src/events/InteractionCreate.js b/bot/src/events/InteractionCreate.js index 4e39241..eadef09 100644 --- a/bot/src/events/InteractionCreate.js +++ b/bot/src/events/InteractionCreate.js @@ -2,7 +2,7 @@ import { Events, MessageFlags } from 'discord.js'; export default { name: Events.InteractionCreate, - async execute(interaction, client) { + async execute(interaction) { if (!interaction.isChatInputCommand()) return; const command = interaction.client.commands.get(interaction.commandName); @@ -10,10 +10,14 @@ export default { if (!command) return; try { - await command.execute(interaction, client); + await command.execute(interaction); } catch (e) { - console.error(e); - await interaction.reply({ content: `Something went wrong. Send the following error message to Alee:\n\`\`\`${e}\`\`\``, flags: MessageFlags.Ephemeral }); + console.log(e); + if (interaction.replied || interaction.deferred) { + await interaction.followUp({ content: `Something went wrong. The following error message:\n\`\`\`${e}\`\`\``, flags: MessageFlags.Ephemeral }); + } else { + await interaction.reply({ content: `Something went wrong. The following error message:\n\`\`\`${e}\`\`\``, flags: MessageFlags.Ephemeral }); + } } } }; -- cgit v1.2.3