From c9c2c99b1012defaef1227b47f1c70cb264771d7 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Wed, 31 Jul 2024 22:15:18 -0600 Subject: [PATCH] misc.color: make colornames dupes list an embed --- src/modules/misc.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/modules/misc.js b/src/modules/misc.js index f4b08d3..58b57a8 100644 --- a/src/modules/misc.js +++ b/src/modules/misc.js @@ -650,7 +650,23 @@ color.callback = async function (msg, line, args, {truerandom, first}) { const colornamesMatches = colornamesRaw.match(new RegExp(search, "img")); if (colornamesMatches.length > 1) { const hexes = colornamesMatches.map((m) => m.split(",")[0]); - return `Got ${colornamesMatches.length} matches for \`${safeString(line)}\`\n- ${hexes.join("\n- ")}`; + const random = hexes[Math.floor(Math.random() * hexes.length)]; + + const left = "- #" + hexes.slice(0, Math.ceil(hexes.length / 2)).join("\n- #"); + const right = "- #" + hexes.slice(Math.ceil(hexes.length / 2), hexes.length).join("\n- #"); + + return { + embed: { + color: parseInt(`0x${random}`), + footer: { + text: `Picked #${random} for embed color \u2022 Use \`--first\` or the \`first\` option to bypass this`, + }, + fields: [ + {name: `Got ${colornamesMatches.length} matches for`, value: left, inline: true}, + {name: `\`${safeString(line)}\``, value: right, inline: true}, + ], + }, + }; } }