fix invalid chatlogs webhook

This commit is contained in:
Erik 2022-07-24 18:21:56 +03:00
parent a77ee0f3d4
commit 48d7eb97e3
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -241,8 +241,13 @@ class GuildWrapper {
if (!result) return null;
if (!this.me.permissions.has('ManageWebhooks')) throw new Error('Missing ManageWebhooks');
const hooks = await this.fetchWebhooks();
const hook = hooks.get(result.hookID);
let hook = hooks.get(result.hookID);
if (!hook) return null;
if (!hook.token) { // Happens when the webhook from imported settings is used, replace it.
const channel = await this.resolveChannel(hook.channelId);
await hook.delete('Old hook');
hook = await channel.createWebhook({ name: 'Galactic Bot message logs' });
}
// const hook = new WebhookClient(result.hookID, result.token, {
// disableMentions: 'everyone'
// });