Skip to content

Commit

Permalink
refactor(Interaction): use enum
Browse files Browse the repository at this point in the history
  • Loading branch information
monbrey committed Jun 24, 2021
1 parent 8d242f2 commit 33f284e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions 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');

/**
Expand Down Expand Up @@ -126,15 +126,21 @@ 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
);
}

/**
* Indicates whether this interaction is a select menu interaction.
* @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
);
}
}

Expand Down

0 comments on commit 33f284e

Please sign in to comment.