diff --git a/src/commands/ask.ts b/src/commands/ask.ts index f327852..046a2bb 100644 --- a/src/commands/ask.ts +++ b/src/commands/ask.ts @@ -10,7 +10,7 @@ import { Discord, Slash, SlashChoice, SlashOption } from 'discordx' const COMMAND_NAME = 'ask' const COMMAND_DESC = 'Ask a question to Wolfram Alpha' -const COOLDOWN_MILLISECONDS = 3 * 60 * 1000 +const COOLDOWN_MILLISECONDS = 30 * 1000 @Discord() class Ask { @@ -56,8 +56,8 @@ class Ask { const capitalizedAnswer = answer.charAt(0).toUpperCase() + answer.slice(1) const embed = new EmbedBuilder() .setColor('#FBAB00') // MasterMind's color - .setTitle(escapeMarkdown(question)) - .setDescription(capitalizedAnswer) + .setTitle(truncate(escapeMarkdown(question).trim(), 256)) + .setDescription(truncate(capitalizedAnswer.trim(), 4096)) return await interaction.reply({ embeds: [embed] }) } catch (err) { @@ -106,3 +106,11 @@ class Ask { return null } } + +function truncate(text: string, maxLength: number): string { + if (text.length <= maxLength) { + return text + } + + return text.substring(0, maxLength - 3).trim() + '...' +}