From 33f284eed8816fc6a11f472047f0fe03f038a40e Mon Sep 17 00:00:00 2001 From: Monbrey Date: Mon, 21 Jun 2021 08:33:12 +1000 Subject: [PATCH] refactor(Interaction): use enum --- src/structures/Interaction.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/structures/Interaction.js b/src/structures/Interaction.js index fd76766fb8b9..189b3de03ec3 100644 --- a/src/structures/Interaction.js +++ b/src/structures/Interaction.js @@ -1,7 +1,7 @@ 'use strict'; const Base = require('./Base'); -const { InteractionTypes } = require('../util/Constants'); +const { InteractionTypes, MessageComponentTypes } = require('../util/Constants'); const SnowflakeUtil = require('../util/SnowflakeUtil'); /** @@ -126,7 +126,10 @@ class Interaction extends Base { * @returns {boolean} */ isButton() { - return InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT && this.componentType === 'BUTTON'; + return ( + InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT && + MessageComponentTypes[this.componentType] === MessageComponentTypes.BUTTON + ); } /** @@ -134,7 +137,10 @@ class Interaction extends Base { * @returns {boolean} */ isSelectMenu() { - return InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT && this.componentType === 'SELECT_MENU'; + return ( + InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT && + MessageComponentTypes[this.componentType] === MessageComponentTypes.SELECT_MENU + ); } }