[Commands] Remove un-needed implementation of seperate REST client. (#22)

This commit is contained in:
2026-10-05 08:36:12 -07:00
committed by GitHub
parent 1757ef2f8a
commit 2581c733a6
2 changed files with 11 additions and 9 deletions
+8 -4
View File
@@ -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 { config } from './config';
import events from './events'; import events from './events';
import { Database } from './shared/Database'; import { Database } from './shared/Database';
@@ -14,7 +14,7 @@ let ready = false;
console.log('Starting...'); console.log('Starting...');
const client = new DiscordClient({ const client = new Client({
intents: [ intents: [
GatewayIntentBits.Guilds, GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessages,
@@ -24,11 +24,15 @@ const client = new DiscordClient({
GatewayIntentBits.MessageContent GatewayIntentBits.MessageContent
], ],
partials: [Partials.Message, Partials.GuildMember, Partials.User, Partials.Channel], partials: [Partials.Message, Partials.GuildMember, Partials.User, Partials.Channel],
rest: { timeout: 30000 },
rest: {
version: '10'
},
allowedMentions: { allowedMentions: {
parse: [], parse: [],
repliedUser: false repliedUser: false
} },
}); });
const commands: Handler[] = []; const commands: Handler[] = [];
+3 -5
View File
@@ -1,4 +1,4 @@
import { Client, REST, RESTPostAPIApplicationCommandsJSONBody, Routes } from 'discord.js'; import { Client, RESTPostAPIApplicationCommandsJSONBody, Routes } from 'discord.js';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { config } from '../config'; import { config } from '../config';
@@ -6,8 +6,6 @@ import { Command } from '../types';
const ROOT_DIR = path.resolve(__dirname, '..'); const ROOT_DIR = path.resolve(__dirname, '..');
const rest = new REST({ version: '10' }).setToken(config.DISCORD_TOKEN!);
export async function refreshCommands(client: Client) { export async function refreshCommands(client: Client) {
try { try {
const commands: RESTPostAPIApplicationCommandsJSONBody[] = []; const commands: RESTPostAPIApplicationCommandsJSONBody[] = [];
@@ -49,14 +47,14 @@ export async function refreshCommands(client: Client) {
console.log('Started refreshing application (/) commands.'); console.log('Started refreshing application (/) commands.');
console.log('Global commands: ' + commands.length); console.log('Global commands: ' + commands.length);
await rest.put( await client.rest.put(
Routes.applicationCommands(config.DISCORD_CLIENT_ID!), Routes.applicationCommands(config.DISCORD_CLIENT_ID!),
{ body: commands } { body: commands }
); );
for (const guild in guildCommands) { for (const guild in guildCommands) {
console.log('Guild commands: ' + guildCommands[guild].length + ' (' + guild + ')'); console.log('Guild commands: ' + guildCommands[guild].length + ' (' + guild + ')');
await rest.put( await client.rest.put(
Routes.applicationGuildCommands(config.DISCORD_CLIENT_ID!, guild), Routes.applicationGuildCommands(config.DISCORD_CLIENT_ID!, guild),
{ body: guildCommands[guild] } { body: guildCommands[guild] }
); );