Skip to content

Commit

Permalink
fix: GuildChannel#guildId not being patched to undefined
Browse files Browse the repository at this point in the history
backport djs v14 #10505
  • Loading branch information
aiko-chan-ai committed Oct 1, 2024
1 parent b5f10f8 commit 9632016
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/client/actions/MessageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ let deprecationEmitted = false;
class MessageCreateAction extends Action {
handle(data) {
const client = this.client;
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id, author: data.author });
const channel = this.getChannel({
id: data.channel_id,
author: data.author,
...('guild_id' in data && { guild_id: data.guild_id }),
});
if (channel) {
if (!channel.isText()) return {};

Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/MessageDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { Events } = require('../../util/Constants');
class MessageDeleteAction extends Action {
handle(data) {
const client = this.client;
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
let message;
if (channel) {
if (!channel.isText()) return {};
Expand Down
6 changes: 5 additions & 1 deletion src/client/actions/MessageReactionAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ class MessageReactionAdd extends Action {
if (!user) return false;

// Verify channel
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id, user_id: data.user_id });
const channel = this.getChannel({
id: data.channel_id,
user_id: data.user_id,
...('guild_id' in data && { guild_id: data.guild_id }),
});
if (!channel || !channel.isText()) return false;

// Verify message
Expand Down
6 changes: 5 additions & 1 deletion src/client/actions/MessageReactionRemove.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ class MessageReactionRemove extends Action {
if (!user) return false;

// Verify channel
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id, user_id: data.user_id });
const channel = this.getChannel({
id: data.channel_id,
user_id: data.user_id,
...('guild_id' in data && { guild_id: data.guild_id }),
});
if (!channel || !channel.isText()) return false;

// Verify message
Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/MessageReactionRemoveAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { Events } = require('../../util/Constants');
class MessageReactionRemoveAll extends Action {
handle(data) {
// Verify channel
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
if (!channel || !channel.isText()) return false;

// Verify message
Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/MessageReactionRemoveEmoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { Events } = require('../../util/Constants');

class MessageReactionRemoveEmoji extends Action {
handle(data) {
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
if (!channel || !channel.isText()) return false;

const message = this.getMessage(data, channel);
Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/MessageUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Action = require('./Action');

class MessageUpdateAction extends Action {
handle(data) {
const channel = this.getChannel({ id: data.channel_id, guild_id: data.guild_id });
const channel = this.getChannel({ id: data.channel_id, ...('guild_id' in data && { guild_id: data.guild_id }) });
if (channel) {
if (!channel.isText()) return {};

Expand Down
2 changes: 1 addition & 1 deletion src/client/actions/TypingStart.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { Events } = require('../../util/Constants');

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

if (!channel.isText()) {
Expand Down

0 comments on commit 9632016

Please sign in to comment.