Skip to content

Commit e3cd960

Browse files
authored
Merge pull request #304 from the-hideout/improve-errors
Send interaction options on error
2 parents 0b2c044 + fd41475 commit e3cd960

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

bot.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Client,
44
GatewayIntentBits,
55
Collection,
6+
AttachmentBuilder,
67
} from 'discord.js';
78

89
import autocomplete from './modules/autocomplete.mjs';
@@ -126,6 +127,12 @@ discordClient.on('interactionCreate', async interaction => {
126127
title: `Error running /${interaction.commandName} command on shard ${discordClient.shard.ids[0]}`,
127128
message: error.stack,
128129
footer: `Command invoked by @${interaction.member.user.username} | ${interaction.member.guild ? `Server: ${interaction.member.guild.name}` : 'DM'}`,
130+
files: [
131+
new AttachmentBuilder(
132+
Buffer.from(JSON.stringify(interaction.options, null, 4), 'utf8'),
133+
{ name: 'options.json' },
134+
),
135+
],
129136
});
130137
}
131138
});

commands/quest.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ const defaultFunction = {
7272
}
7373
embed.setDescription(descriptionParts.join('\n'));
7474

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

7983
const footerParts = [`${task.experience} EXP`];

modules/webhook.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export default async function sendWebhook(message) {
5656
embed.setAuthor({name: message.author, iconURL});
5757
}
5858
return webhookClient.send({
59-
embeds: [embed]
59+
embeds: [embed],
60+
files: message.files,
6061
});
6162
};

0 commit comments

Comments
 (0)