1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 20:30:58 -05:00

Remove unneeded param from fetchers

This commit is contained in:
AnxietyisReal 2024-01-17 06:33:06 +11:00
parent 5c0f238531
commit 11fcbdcad2

View File

@ -14,18 +14,18 @@ export default class HookMgr {
this.webhookId = webhookId; this.webhookId = webhookId;
} }
protected channelFetch = async(client:TClient, channel:ChannelList)=>await client.channels.fetch(config.dcServer.channels[channel]) as Discord.TextChannel; protected channelFetch = async(channel:ChannelList)=>await this.client.channels.fetch(config.dcServer.channels[channel]) as Discord.TextChannel;
protected async fetch(client:TClient, channel:ChannelList, webhookId:Discord.Snowflake) { protected async fetch(channel:ChannelList, webhookId:Discord.Snowflake) {
const hookInstance = await (await this.channelFetch(client, channel)).fetchWebhooks().then(x=>x.find(y=>y.id===webhookId)); const hookInstance = await (await this.channelFetch(channel)).fetchWebhooks().then(x=>x.find(y=>y.id===webhookId));
if (!hookInstance) throw new Error('[HookManager] Webhook not found.'); if (!hookInstance) throw new Error('[HookManager] Webhook not found.');
return hookInstance; return hookInstance;
} }
async send(message:string|Discord.MessagePayload|Discord.WebhookMessageCreateOptions) { async send(message:string|Discord.MessagePayload|Discord.WebhookMessageCreateOptions) {
const hook = await this.fetch(this.client, this.channel, this.webhookId); const hook = await this.fetch(this.channel, this.webhookId);
return hook.send(message).catch(err=>(this.client.channels.resolve(config.dcServer.channels.errors) as Discord.TextChannel).send(`Failed to send a webhook message in #${this.channel}:\n\`\`\`\n${err.message}\n\`\`\``)); return hook.send(message).catch(err=>(this.client.channels.resolve(config.dcServer.channels.errors) as Discord.TextChannel).send(`Failed to send a webhook message in #${this.channel}:\n\`\`\`\n${err.message}\n\`\`\``));
} }
async edit(messageId:Discord.Snowflake, message:string|Discord.MessagePayload|Discord.WebhookMessageEditOptions) { async edit(messageId:Discord.Snowflake, message:string|Discord.MessagePayload|Discord.WebhookMessageEditOptions) {
const hook = await this.fetch(this.client, this.channel, this.webhookId); const hook = await this.fetch(this.channel, this.webhookId);
return hook.editMessage(messageId, message).catch(err=>(this.client.channels.resolve(config.dcServer.channels.errors) as Discord.TextChannel).send(`Failed to edit a webhook message in #${this.channel}:\n\`\`\`\n${err.message}\n\`\`\``)); return hook.editMessage(messageId, message).catch(err=>(this.client.channels.resolve(config.dcServer.channels.errors) as Discord.TextChannel).send(`Failed to edit a webhook message in #${this.channel}:\n\`\`\`\n${err.message}\n\`\`\``));
} }
} }