From 2581c733a65c799674b28d76fe443a0571eaeb3f Mon Sep 17 00:00:00 2001 From: Nix Krystik Date: Mon, 5 Oct 2026 23:36:12 +0800 Subject: [PATCH] [Commands] Remove un-needed implementation of seperate REST client. (#22) --- src/index.ts | 12 ++++++++---- src/utils/refresh-commands.ts | 8 +++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1b79185..ddb79b0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { Client, Client as DiscordClient, GatewayIntentBits, MessageFlags, Partials } from 'discord.js'; +import { Client, GatewayIntentBits, MessageFlags, Partials } from 'discord.js'; import { config } from './config'; import events from './events'; import { Database } from './shared/Database'; @@ -14,7 +14,7 @@ let ready = false; console.log('Starting...'); -const client = new DiscordClient({ +const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, @@ -24,11 +24,15 @@ const client = new DiscordClient({ GatewayIntentBits.MessageContent ], partials: [Partials.Message, Partials.GuildMember, Partials.User, Partials.Channel], - rest: { timeout: 30000 }, + + rest: { + version: '10' + }, + allowedMentions: { parse: [], repliedUser: false - } + }, }); const commands: Handler[] = []; diff --git a/src/utils/refresh-commands.ts b/src/utils/refresh-commands.ts index 244f2c0..030d8ae 100644 --- a/src/utils/refresh-commands.ts +++ b/src/utils/refresh-commands.ts @@ -1,4 +1,4 @@ -import { Client, REST, RESTPostAPIApplicationCommandsJSONBody, Routes } from 'discord.js'; +import { Client, RESTPostAPIApplicationCommandsJSONBody, Routes } from 'discord.js'; import fs from 'fs'; import path from 'path'; import { config } from '../config'; @@ -6,8 +6,6 @@ import { Command } from '../types'; const ROOT_DIR = path.resolve(__dirname, '..'); -const rest = new REST({ version: '10' }).setToken(config.DISCORD_TOKEN!); - export async function refreshCommands(client: Client) { try { const commands: RESTPostAPIApplicationCommandsJSONBody[] = []; @@ -49,14 +47,14 @@ export async function refreshCommands(client: Client) { console.log('Started refreshing application (/) commands.'); console.log('Global commands: ' + commands.length); - await rest.put( + await client.rest.put( Routes.applicationCommands(config.DISCORD_CLIENT_ID!), { body: commands } ); for (const guild in guildCommands) { console.log('Guild commands: ' + guildCommands[guild].length + ' (' + guild + ')'); - await rest.put( + await client.rest.put( Routes.applicationGuildCommands(config.DISCORD_CLIENT_ID!, guild), { body: guildCommands[guild] } );