From c786867bd65d8f6661e3de9c9528768d1ec03d46 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sun, 18 Aug 2019 11:45:28 +0200 Subject: [PATCH] fix(Webhook): return raw data if the channel is unavailable Fixes #3424 --- src/structures/Webhook.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index 6c1a3db50251..2dc1a0282b78 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -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); }); } @@ -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); }); }