evobot
evobot copied to clipboard
🐛 Consider using try/catch instead of simply do ``return reply....``
Describe the bug A description of what the bug is.
How To Reproduce Steps to reproduce the behavior:
- Miss setting up a role or having a dangerous login bug
- let the bot crash because there is no try/crash to deal with exceptions.
Expected behavior No more to say, juste use try/catch to deal with exceptions.
Additional information & screenshots
miousic ready!
/home/evobot/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/evobot/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async BurstHandler.runRequest (/home/evobot/node_modules/@discordjs/rest/dist/index.js:786:23)
at async _REST.request (/home/evobot/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ChatInputCommandInteraction.reply (/home/evobot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:111:5)
at async Object.execute (/home/evobot/dist/commands/play.js:46:13) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: '⏳ Loading...',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/youRealyWantMyToken/dontYou?/callback'
}
> [email protected] prod
> npm run build && node ./dist/index.js
> [email protected] build
> tsc --build
for example
if (queue && channel.id !== queue.connection.joinConfig.channelId)
return interaction
.reply({
content: i18n.__mf("play.errorNotInSameChannel", { user: bot.client.user!.username }),
ephemeral: true
})
.catch(console.error);
if (!argSongName)
return interaction
.reply({ content: i18n.__mf("play.usageReply", { prefix: bot.prefix }), ephemeral: true })
.catch(console.error);
const url = argSongName;
if (interaction.replied) await interaction.editReply("⏳ Loading...").catch(console.error);
else await interaction.reply("⏳ Loading...");
// Start the playlist if playlist url was provided
if (playlistPattern.test(url)) {
await interaction.editReply("🔗 Link is playlist").catch(console.error);
return bot.slashCommandsMap.get("playlist")!.execute(interaction, "song");
}
a try/catch is also needed for
else await interaction.reply("⏳ Loading...");
try/catch should be everywhere a world of try/catch try/catch try/catch try/catch try/catch (sorry)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Handled in latest release