From 18853be6649b79f3120470950b878b9e98512427 Mon Sep 17 00:00:00 2001 From: dakedres Date: Sat, 20 May 2023 03:55:32 -0600 Subject: [PATCH] Fix an issue with long dice expressions and description length limits --- src/constants.js | 1 + src/index.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/constants.js b/src/constants.js index 7d0668f..91330e6 100644 --- a/src/constants.js +++ b/src/constants.js @@ -39,6 +39,7 @@ ${error.toString()} \`\`\` If this issue persists please report it here: \ `, + aboutMessage: (guildCount) => `\ A discord bot for metaphorically "rolling dice"/generating random values. Made for use with Weaverdice systems. diff --git a/src/index.js b/src/index.js index 1a10bfd..52baf5f 100644 --- a/src/index.js +++ b/src/index.js @@ -203,7 +203,7 @@ const registerMacroCommands = async guildId => { for await (let [ name, dice ] of macros.iterator() ) commands.push({ name, - description: "Roll " + dice.replaceAll('\n', ';') + description: elipsify("Roll " + dice.replaceAll('\n', ';'), 100) }) await rest.put( @@ -212,6 +212,9 @@ const registerMacroCommands = async guildId => { ) } +const elipsify = (string, maxLength) => + string.length > maxLength ? string.slice(0, maxLength - 3) + '...' : string + const pruneDB = async () => { let validIds = [] @@ -291,7 +294,6 @@ addCommand( // return // } - await interaction.deferReply() let macros = openMacros(interaction.guild.id)