Skip to content

Commit

Permalink
fix(Webhook): return raw data if the channel is unavailable
Browse files Browse the repository at this point in the history
Fixes #3424
  • Loading branch information
SpaceEEC committed Aug 18, 2019
1 parent 1851f74 commit c786867
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/structures/Webhook.js
Expand Up @@ -146,8 +146,9 @@ class Webhook {
query: { wait: true },
auth: false,
}).then(d => {
if (!this.client.channels) return d;
return this.client.channels.get(d.channel_id).messages.add(d, false);
const channel = this.client.channels ? this.client.channels.get(d.channel_id) : undefined;
if (!channel) return d;
return channel.messages.add(d, false);
});
}

Expand All @@ -173,9 +174,10 @@ class Webhook {
query: { wait: true },
auth: false,
data: body,
}).then(data => {
if (!this.client.channels) return data;
return this.client.channels.get(data.channel_id).messages.add(data, false);
}).then(d => {
const channel = this.client.channels ? this.client.channels.get(d.channel_id) : undefined;
if (!channel) return d;
return channel.messages.add(d, false);
});
}

Expand Down

0 comments on commit c786867

Please sign in to comment.