djs-systems
Version:
The simplest way to build complex Discord bots.
33 lines (32 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toButtonStyle = void 0;
const discord_js_1 = require("discord.js");
/**
* Converts your old button style string to [ButtonStyle](https://discord-api-types.dev/api/discord-api-types-v10/enum/ButtonStyle)
* @param style
* @link `Documentation:` https://simplyd.js.org/docs/misc/toButtonStyle
* @example simplydjs.toButtonStyle("PRIMARY")
*/
function toButtonStyle(style) {
// The style options are optional so if its undefined just don't care
if (style == undefined)
return;
// The combination to find
const combination = [
{ key: 'PRIMARY', value: discord_js_1.ButtonStyle.Primary },
{ key: 'SECONDARY', value: discord_js_1.ButtonStyle.Secondary },
{ key: 'SUCCESS', value: discord_js_1.ButtonStyle.Success },
{ key: 'DANGER', value: discord_js_1.ButtonStyle.Danger },
{ key: 'LINK', value: discord_js_1.ButtonStyle.Link }
];
// Using .find(callback) to get the combination
const buttonstyle = combination.find((o) => o.key == style);
// If it doesn't exist just return nothing
if (Number(style) >= 1 && Number(style) <= 5)
return Number(style);
if (!buttonstyle || buttonstyle == undefined)
return;
return buttonstyle.value;
}
exports.toButtonStyle = toButtonStyle;