mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
fix: assert channel types in message actions (#6919)
This commit is contained in:
@@ -10,6 +10,8 @@ class MessageCreateAction extends Action {
|
|||||||
const client = this.client;
|
const client = this.client;
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
|
if (!channel.isText()) return {};
|
||||||
|
|
||||||
const existing = channel.messages.cache.get(data.id);
|
const existing = channel.messages.cache.get(data.id);
|
||||||
if (existing) return { message: existing };
|
if (existing) return { message: existing };
|
||||||
const message = channel.messages._add(data);
|
const message = channel.messages._add(data);
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ class MessageDeleteAction extends Action {
|
|||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
let message;
|
let message;
|
||||||
if (channel) {
|
if (channel) {
|
||||||
|
if (!channel.isText()) return {};
|
||||||
|
|
||||||
message = this.getMessage(data, channel);
|
message = this.getMessage(data, channel);
|
||||||
if (message) {
|
if (message) {
|
||||||
channel.messages.cache.delete(message.id);
|
channel.messages.cache.delete(message.id);
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ class MessageDeleteBulkAction extends Action {
|
|||||||
const channel = client.channels.cache.get(data.channel_id);
|
const channel = client.channels.cache.get(data.channel_id);
|
||||||
|
|
||||||
if (channel) {
|
if (channel) {
|
||||||
|
if (!channel.isText()) return {};
|
||||||
|
|
||||||
const ids = data.ids;
|
const ids = data.ids;
|
||||||
const messages = new Collection();
|
const messages = new Collection();
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events, VoiceBasedChannelTypes } = require('../../util/Constants');
|
const { Events } = require('../../util/Constants');
|
||||||
const { PartialTypes } = require('../../util/Constants');
|
const { PartialTypes } = require('../../util/Constants');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -23,7 +23,7 @@ class MessageReactionAdd extends Action {
|
|||||||
|
|
||||||
// Verify channel
|
// Verify channel
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (!channel || VoiceBasedChannelTypes.includes(channel.type)) return false;
|
if (!channel || !channel.isText()) return false;
|
||||||
|
|
||||||
// Verify message
|
// Verify message
|
||||||
const message = this.getMessage(data, channel);
|
const message = this.getMessage(data, channel);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events, VoiceBasedChannelTypes } = require('../../util/Constants');
|
const { Events } = require('../../util/Constants');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{ user_id: 'id',
|
{ user_id: 'id',
|
||||||
@@ -20,7 +20,7 @@ class MessageReactionRemove extends Action {
|
|||||||
|
|
||||||
// Verify channel
|
// Verify channel
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (!channel || VoiceBasedChannelTypes.includes(channel.type)) return false;
|
if (!channel || !channel.isText()) return false;
|
||||||
|
|
||||||
// Verify message
|
// Verify message
|
||||||
const message = this.getMessage(data, channel);
|
const message = this.getMessage(data, channel);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events, VoiceBasedChannelTypes } = require('../../util/Constants');
|
const { Events } = require('../../util/Constants');
|
||||||
|
|
||||||
class MessageReactionRemoveAll extends Action {
|
class MessageReactionRemoveAll extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
// Verify channel
|
// Verify channel
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (!channel || VoiceBasedChannelTypes.includes(channel.type)) return false;
|
if (!channel || !channel.isText()) return false;
|
||||||
|
|
||||||
// Verify message
|
// Verify message
|
||||||
const message = this.getMessage(data, channel);
|
const message = this.getMessage(data, channel);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events, VoiceBasedChannelTypes } = require('../../util/Constants');
|
const { Events } = require('../../util/Constants');
|
||||||
|
|
||||||
class MessageReactionRemoveEmoji extends Action {
|
class MessageReactionRemoveEmoji extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (!channel || VoiceBasedChannelTypes.includes(channel.type)) return false;
|
if (!channel || !channel.isText()) return false;
|
||||||
|
|
||||||
const message = this.getMessage(data, channel);
|
const message = this.getMessage(data, channel);
|
||||||
if (!message) return false;
|
if (!message) return false;
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ class MessageUpdateAction extends Action {
|
|||||||
handle(data) {
|
handle(data) {
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
|
if (!channel.isText()) return {};
|
||||||
|
|
||||||
const { id, channel_id, guild_id, author, timestamp, type } = data;
|
const { id, channel_id, guild_id, author, timestamp, type } = data;
|
||||||
const message = this.getMessage({ id, channel_id, guild_id, author, timestamp, type }, channel);
|
const message = this.getMessage({ id, channel_id, guild_id, author, timestamp, type }, channel);
|
||||||
if (message) {
|
if (message) {
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const Typing = require('../../structures/Typing');
|
const Typing = require('../../structures/Typing');
|
||||||
const { Events, TextBasedChannelTypes } = require('../../util/Constants');
|
const { Events } = require('../../util/Constants');
|
||||||
|
|
||||||
class TypingStart extends Action {
|
class TypingStart extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (!channel) return;
|
if (!channel) return;
|
||||||
|
|
||||||
if (!TextBasedChannelTypes.includes(channel.type)) {
|
if (!channel.isText()) {
|
||||||
this.client.emit(Events.WARN, `Discord sent a typing packet to a ${channel.type} channel ${channel.id}`);
|
this.client.emit(Events.WARN, `Discord sent a typing packet to a ${channel.type} channel ${channel.id}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user