Skip to content

Commit

Permalink
send interaction options on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Aug 15, 2024
1 parent 0b2c044 commit fd41475
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions bot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Client,
GatewayIntentBits,
Collection,
AttachmentBuilder,
} from 'discord.js';

import autocomplete from './modules/autocomplete.mjs';
Expand Down Expand Up @@ -126,6 +127,12 @@ discordClient.on('interactionCreate', async interaction => {
title: `Error running /${interaction.commandName} command on shard ${discordClient.shard.ids[0]}`,
message: error.stack,
footer: `Command invoked by @${interaction.member.user.username} | ${interaction.member.guild ? `Server: ${interaction.member.guild.name}` : 'DM'}`,
files: [
new AttachmentBuilder(
Buffer.from(JSON.stringify(interaction.options, null, 4), 'utf8'),
{ name: 'options.json' },
),
],
});
}
});
Expand Down
6 changes: 5 additions & 1 deletion commands/quest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ const defaultFunction = {
}
embed.setDescription(descriptionParts.join('\n'));

let objectivesText = task.objectives.map(obj => `${obj.description}${obj.count > 1 ? ` (x${obj.count})` : ''}`).join('\n');
if (objectivesText.length > 1024) {
objectivesText = objectivesText.substring(0, 1021) + '...';
}
embed.addFields(
{ name: t('Objectives'), value: task.objectives.map(obj => `${obj.description}${obj.count > 1 ? ` (x${obj.count})` : ''}`).join('\n'), inline: false },
{ name: t('Objectives'), value: objectivesText, inline: false },
);

const footerParts = [`${task.experience} EXP`];
Expand Down
3 changes: 2 additions & 1 deletion modules/webhook.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default async function sendWebhook(message) {
embed.setAuthor({name: message.author, iconURL});
}
return webhookClient.send({
embeds: [embed]
embeds: [embed],
files: message.files,
});
};

0 comments on commit fd41475

Please sign in to comment.