Fix an issue with long dice expressions and description length limits

This commit is contained in:
dakedres 2023-05-20 03:55:32 -06:00
parent 49da6d8041
commit 18853be664
2 changed files with 5 additions and 2 deletions

View File

@ -39,6 +39,7 @@ ${error.toString()}
\`\`\` \`\`\`
If this issue persists please report it here: <https://github.com/Dakedres/dicedicedice/issues>\ If this issue persists please report it here: <https://github.com/Dakedres/dicedicedice/issues>\
`, `,
aboutMessage: (guildCount) => `\ aboutMessage: (guildCount) => `\
A discord bot for metaphorically "rolling dice"/generating random values. Made for use with Weaverdice systems. A discord bot for metaphorically "rolling dice"/generating random values. Made for use with Weaverdice systems.

View File

@ -203,7 +203,7 @@ const registerMacroCommands = async guildId => {
for await (let [ name, dice ] of macros.iterator() ) for await (let [ name, dice ] of macros.iterator() )
commands.push({ commands.push({
name, name,
description: "Roll " + dice.replaceAll('\n', ';') description: elipsify("Roll " + dice.replaceAll('\n', ';'), 100)
}) })
await rest.put( 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 () => { const pruneDB = async () => {
let validIds = [] let validIds = []
@ -291,7 +294,6 @@ addCommand(
// return // return
// } // }
await interaction.deferReply() await interaction.deferReply()
let macros = openMacros(interaction.guild.id) let macros = openMacros(interaction.guild.id)