Skip to content

Commit 2adee06

Browse files
authoredSep 14, 2024··
fix: GuildChannel#guildId not being patched to undefined (#10505)
* fix: `GuildChannel#guildId` not being patched to `undefined` * fix: guildId to guild_id check
1 parent 495bc60 commit 2adee06

10 files changed

+18
-10
lines changed
 

‎packages/discord.js/src/client/actions/MessageCreate.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ const Events = require('../../util/Events');
66
class MessageCreateAction extends Action {
77
handle(data) {
88
const client = this.client;
9-
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id, author: data.author });
9+
const channel = this.getChannel({
10+
id: data.channel_id,
11+
author: data.author,
12+
...('guild_id' in data && { guild_id: data.guild_id }),
13+
});
1014
if (channel) {
1115
if (!channel.isTextBased()) return {};
1216

‎packages/discord.js/src/client/actions/MessageDelete.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Events = require('../../util/Events');
66
class MessageDeleteAction extends Action {
77
handle(data) {
88
const client = this.client;
9-
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
9+
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
1010
let message;
1111
if (channel) {
1212
if (!channel.isTextBased()) return {};

‎packages/discord.js/src/client/actions/MessagePollVoteAdd.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Events = require('../../util/Events');
55

66
class MessagePollVoteAddAction extends Action {
77
handle(data) {
8-
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
8+
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
99
if (!channel?.isTextBased()) return false;
1010

1111
const message = this.getMessage(data, channel);

‎packages/discord.js/src/client/actions/MessagePollVoteRemove.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Events = require('../../util/Events');
55

66
class MessagePollVoteRemoveAction extends Action {
77
handle(data) {
8-
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
8+
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
99
if (!channel?.isTextBased()) return false;
1010

1111
const message = this.getMessage(data, channel);

‎packages/discord.js/src/client/actions/MessageReactionAdd.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MessageReactionAdd extends Action {
2525
// Verify channel
2626
const channel = this.getChannel({
2727
id: data.channel_id,
28-
guild_id: data.guild_id,
28+
...('guild_id' in data && { guild_id: data.guild_id }),
2929
user_id: data.user_id,
3030
...this.spreadInjectedData(data),
3131
});

‎packages/discord.js/src/client/actions/MessageReactionRemove.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ class MessageReactionRemove extends Action {
1919
if (!user) return false;
2020

2121
// Verify channel
22-
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id, user_id: data.user_id });
22+
const channel = this.getChannel({
23+
id: data.channel_id,
24+
...('guild_id' in data && { guild_id: data.guild_id }),
25+
user_id: data.user_id,
26+
});
2327
if (!channel?.isTextBased()) return false;
2428

2529
// Verify message

‎packages/discord.js/src/client/actions/MessageReactionRemoveAll.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Events = require('../../util/Events');
66
class MessageReactionRemoveAll extends Action {
77
handle(data) {
88
// Verify channel
9-
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
9+
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
1010
if (!channel?.isTextBased()) return false;
1111

1212
// Verify message

‎packages/discord.js/src/client/actions/MessageReactionRemoveEmoji.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Events = require('../../util/Events');
55

66
class MessageReactionRemoveEmoji extends Action {
77
handle(data) {
8-
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
8+
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
99
if (!channel?.isTextBased()) return false;
1010

1111
const message = this.getMessage(data, channel);

‎packages/discord.js/src/client/actions/MessageUpdate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Action = require('./Action');
44

55
class MessageUpdateAction extends Action {
66
handle(data) {
7-
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
7+
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
88
if (channel) {
99
if (!channel.isTextBased()) return {};
1010

‎packages/discord.js/src/client/actions/TypingStart.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Events = require('../../util/Events');
66

77
class TypingStart extends Action {
88
handle(data) {
9-
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
9+
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
1010
if (!channel) return;
1111

1212
if (!channel.isTextBased()) {

0 commit comments

Comments
 (0)
Please sign in to comment.