Skip to content

Commit

Permalink
fix: channel type check in actions (#6086)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImRodry committed Jul 10, 2021
1 parent f72ce7c commit d433fe8
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/client/actions/GuildDelete.js
Expand Up @@ -15,7 +15,7 @@ class GuildDeleteAction extends Action {
let guild = client.guilds.cache.get(data.id);
if (guild) {
for (const channel of guild.channels.cache.values()) {
if (channel.type in TextBasedChannelTypes) channel.stopTyping(true);
if (TextBasedChannelTypes.includes(channel.type)) channel.stopTyping(true);
}

if (data.unavailable) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/MessageReactionAdd.js
Expand Up @@ -23,7 +23,7 @@ class MessageReactionAdd extends Action {

// Verify channel
const channel = this.getChannel(data);
if (!channel || channel.type in VoiceBasedChannelTypes) return false;
if (!channel || VoiceBasedChannelTypes.includes(channel.type)) return false;

// Verify message
const message = this.getMessage(data, channel);
Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/MessageReactionRemove.js
Expand Up @@ -20,7 +20,7 @@ class MessageReactionRemove extends Action {

// Verify channel
const channel = this.getChannel(data);
if (!channel || channel.type in VoiceBasedChannelTypes) return false;
if (!channel || VoiceBasedChannelTypes.includes(channel.type)) return false;

// Verify message
const message = this.getMessage(data, channel);
Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/MessageReactionRemoveAll.js
Expand Up @@ -7,7 +7,7 @@ class MessageReactionRemoveAll extends Action {
handle(data) {
// Verify channel
const channel = this.getChannel(data);
if (!channel || channel.type in VoiceBasedChannelTypes) return false;
if (!channel || VoiceBasedChannelTypes.includes(channel.type)) return false;

// Verify message
const message = this.getMessage(data, channel);
Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/MessageReactionRemoveEmoji.js
Expand Up @@ -6,7 +6,7 @@ const { Events, VoiceBasedChannelTypes } = require('../../util/Constants');
class MessageReactionRemoveEmoji extends Action {
handle(data) {
const channel = this.getChannel(data);
if (!channel || channel.type in VoiceBasedChannelTypes) return false;
if (!channel || VoiceBasedChannelTypes.includes(channel.type)) return false;

const message = this.getMessage(data, channel);
if (!message) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/TypingStart.js
Expand Up @@ -9,7 +9,7 @@ class TypingStart extends Action {
if (!channel) {
return;
}
if (!(channel.type in TextBasedChannelTypes)) {
if (!TextBasedChannelTypes.includes(channel.type)) {
this.client.emit(Events.WARN, `Discord sent a typing packet to a ${channel.type} channel ${channel.id}`);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/structures/GuildChannel.js
Expand Up @@ -573,7 +573,7 @@ class GuildChannel extends Channel {
*/
get manageable() {
if (this.client.user.id === this.guild.ownerId) return true;
if (this.type in VoiceBasedChannelTypes) {
if (VoiceBasedChannelTypes.includes(this.type)) {
if (!this.permissionsFor(this.client.user).has(Permissions.FLAGS.CONNECT, false)) {
return false;
}
Expand Down

0 comments on commit d433fe8

Please sign in to comment.