Skip to content

Commit

Permalink
fix: don't rely on #channel if not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
almostSouji committed Aug 2, 2021
1 parent 5ac114d commit c44c541
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class Message extends Base {
}

if (data.referenced_message) {
this.channel.messages._add(data.referenced_message);
this.channel?.messages._add(data.referenced_message);
}

/**
Expand Down Expand Up @@ -410,7 +410,7 @@ class Message extends Base {
* @readonly
*/
get thread() {
return this.channel.threads.resolve(this.id);
return this.channel?.threads.resolve(this.id) ?? null;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/structures/MessagePayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@ class MessagePayload {

let message_reference;
if (typeof this.options.reply === 'object') {
const message_id = this.isMessage
? this.target.channel.messages.resolveId(this.options.reply.messageReference)
: this.target.messages.resolveId(this.options.reply.messageReference);
const reference = this.options.reply.messageReference;
const message_id = this.isMessage ? reference.id ?? reference : this.target.messages.resolveId(reference);
if (message_id) {
message_reference = {
message_id,
Expand Down

0 comments on commit c44c541

Please sign in to comment.