From 07e2a68d069d97d0357035d2bfee94a8e121b19e Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Mon, 25 Dec 2023 18:56:28 +0100 Subject: [PATCH] v3.5.1 push 2 (fix button color bug) --- core/utils/getButton.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/core/utils/getButton.js b/core/utils/getButton.js index 36348a5..06cfd08 100644 --- a/core/utils/getButton.js +++ b/core/utils/getButton.js @@ -2,22 +2,26 @@ const discord = require("discord.js") const bot = require("../../index") const config = bot.config const l = bot.language +const b = discord.ButtonStyle -/**@returns {"DANGER"|"SUCCESS"|"PRIMARY"|"SECONDARY"} */ +/** + * @param {String} color + * @returns {"DANGER"|"SUCCESS"|"PRIMARY"|"SECONDARY"} */ const getColor = (color) => { - const b = discord.ButtonStyle - if (color.toLowerCase() == "red"){ - return b.Danger - }else if (color.toLowerCase() == "green"){ - return b.Success - }else if (color.toLowerCase() == "blue" || color.toLowerCase() == "blurple"){ - return b.Primary - }else if (color.toLowerCase() == "black" || color.toLowerCase() == "gray" || color.toLowerCase() == "grey"){ - return b.Secondary - }else if (color == "DANGER" || color == "SECONDARY" || color == "SUCCESS" || color == "PRIMARY"){ - return color - }else if (color.toLowerCase() == "none" || color.toLowerCase() == "false" || color.toLowerCase() == ""){ - return b.Secondary + if (color){ + if (color.toLowerCase() == "red"){ + return b.Danger + }else if (color.toLowerCase() == "green"){ + return b.Success + }else if (color.toLowerCase() == "blue" || color.toLowerCase() == "blurple"){ + return b.Primary + }else if (color.toLowerCase() == "black" || color.toLowerCase() == "gray" || color.toLowerCase() == "grey"){ + return b.Secondary + }else if (color.toUpperCase() == "DANGER" || color.toUpperCase() == "SECONDARY" || color.toUpperCase() == "SUCCESS" || color.toUpperCase() == "PRIMARY"){ + return color + }else if (color.toLowerCase() == "none" || color.toLowerCase() == "false" || color.toLowerCase() == ""){ + return b.Secondary + }else return b.Secondary }else return b.Secondary }