From 5388b25869b5f20cbbf051308dbd8aa4167343fc Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Fri, 25 Aug 2023 09:15:56 +1000 Subject: [PATCH] Drop WClient from client.ts --- src/client.ts | 10 +--------- src/commands/dev.ts | 4 ++-- src/commands/suggest.ts | 6 +++--- src/config.json | 1 + src/typings/interfaces.d.ts | 3 +-- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/client.ts b/src/client.ts index 5c9e3a7..e39e9a1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,4 +1,4 @@ -import Discord, {Client, WebhookClient, GatewayIntentBits, Partials} from 'discord.js'; +import Discord, {Client, GatewayIntentBits, Partials} from 'discord.js'; import {readFileSync, readdirSync} from 'node:fs'; import {formatTimeOpt, Tokens, Config, repeatedMessages, type MPServerCache} from './typings/interfaces'; import bannedWords from './models/bannedWords.js'; @@ -212,11 +212,3 @@ export default class TClient extends Client { } return array.join(dirSlash); } } - -export class WClient extends WebhookClient { - tokens: Tokens; - constructor(){ - super({url: tokens.webhook_url}) - this.tokens = tokens as Tokens; - } -} diff --git a/src/commands/dev.ts b/src/commands/dev.ts index 2bda117..541e037 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -34,8 +34,8 @@ export default { if (typeof output === 'object') output = 'js\n'+util.formatWithOptions({depth: 1}, '%O', output) else output = '\n' + String(output); [ - client.tokens.main,client.tokens.beta,client.tokens.toast,client.tokens.webhook_url, - client.tokens.webhook_url_test,client.tokens.mongodb_uri,client.tokens.mongodb_uri_dev,client.tokens.octokit + client.tokens.main,client.tokens.beta,client.tokens.toast,client.tokens.dontlookatme.client,client.tokens.dontlookatme.secret, + client.tokens.mongodb_uri,client.tokens.mongodb_uri_dev,client.tokens.octokit ].forEach(x=>output = output.replace(new RegExp(x as string,'g'),':noblank: No token?')); const embed = new client.embed().setColor(client.config.embedColor).setTitle('__Eval__').addFields( {name: 'Input', value: `\`\`\`js\n${code.slice(0,1010)}\n\`\`\``}, diff --git a/src/commands/suggest.ts b/src/commands/suggest.ts index a2ca9ad..a2d163c 100644 --- a/src/commands/suggest.ts +++ b/src/commands/suggest.ts @@ -1,5 +1,5 @@ import Discord from 'discord.js'; -import TClient,{WClient} from '../client.js'; +import TClient from '../client.js'; export default { async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ const replyInDM = interaction.options.getString('message'); @@ -12,7 +12,7 @@ export default { const dmFail = `Failed to send a DM to <@${userid}>, they possibly have it turned off or blocked me.\nSuggestion ID: **${suggestionIDReply}**`; ({ your: async()=>{ - const wclient = new WClient; + const webhook = await (await (client.channels.fetch(client.config.mainServer.channels.bot_suggestions) as Promise)).fetchWebhooks().then(x => x.find(y => y.name === client.user.username)); const suggestionText = interaction.options.getString('suggestion'); const suggestionImage = interaction.options.getAttachment('image'); const notifEmbed = new client.embed() @@ -25,7 +25,7 @@ export default { suggestionText ].join('\n')); if (suggestionImage) notifEmbed.setImage(suggestionImage.url); - wclient.send({embeds: [notifEmbed], username: `${client.user.username} Notification`, avatarURL: client.user.avatarURL({size: 256})} + webhook.send({embeds: [notifEmbed], username: `${client.user.username} Notification`, avatarURL: client.user.avatarURL({size: 256})} ).catch(e=>{ console.log(e.message); interaction.reply({content: 'Failed to send suggestion, try again later.', ephemeral: true}) diff --git a/src/config.json b/src/config.json index fc5422a..c3986b4 100644 --- a/src/config.json +++ b/src/config.json @@ -81,6 +81,7 @@ "console": "1011318687065710663", "errors": "1009754872188506192", "thismeanswar": "1091300529696673792", + "bot_suggestions": "1040018521746325586", "bot_status": "1009753780188884992", "logs": "548032776830582794", "welcome": "621134751897616406", diff --git a/src/typings/interfaces.d.ts b/src/typings/interfaces.d.ts index 850ad13..6210bcb 100644 --- a/src/typings/interfaces.d.ts +++ b/src/typings/interfaces.d.ts @@ -121,8 +121,6 @@ export interface Tokens { secret: string } octokit: string - webhook_url: string - webhook_url_test: string mongodb_uri: string mongodb_uri_dev: string } @@ -181,6 +179,7 @@ export interface Config { console: string, errors: string, thismeanswar: string, + bot_suggestions: string, bot_status: string, logs: string, welcome: string,