From f4fa935a134075be96bf5bdf58832361f45c8592 Mon Sep 17 00:00:00 2001 From: Matteo Juen Date: Thu, 24 Oct 2024 21:52:19 +0200 Subject: [PATCH] fix: deploy commands to all servers, register on all --- .env.sample | 3 --- src/deployment/deploy.service.ts | 23 +++++++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.env.sample b/.env.sample index c40eeaa..bf3df0f 100644 --- a/.env.sample +++ b/.env.sample @@ -2,9 +2,6 @@ BOT_TOKEN = #used for adding bot/application to server CLIENT_ID = -# invite link: -# https://discord.com/api/oauth2/authorize?CLIENT_ID=&permissions=0&scope=bot%20applications.commands -SERVER_ID = # Mongo configuration MONGO_URI= MONGO_PORT= diff --git a/src/deployment/deploy.service.ts b/src/deployment/deploy.service.ts index c3775e1..9988b22 100644 --- a/src/deployment/deploy.service.ts +++ b/src/deployment/deploy.service.ts @@ -1,4 +1,8 @@ -import { REST, RESTPostAPIChatInputApplicationCommandsJSONBody, Routes } from 'discord.js'; +import { + REST, + RESTPostAPIChatInputApplicationCommandsJSONBody, + Routes, +} from 'discord.js'; import { Injectable } from '@nestjs/common'; import { CommandService } from '../modules/command/command.service'; import { AppConfigService } from '../config/config.service'; @@ -18,18 +22,25 @@ export class DeployServcice { return commands.map((command) => command.data.toJSON()); } - async deployCommands(commands: RESTPostAPIChatInputApplicationCommandsJSONBody[]) { + async deployCommands( + commands: RESTPostAPIChatInputApplicationCommandsJSONBody[], + ) { // Construct and prepare an instance of the REST module const rest = new REST().setToken(this.configService.botToken); // and deploy your commands! try { - console.log(`Started refreshing ${commands.length} application (/) commands.`); + console.log( + `Started refreshing ${commands.length} application (/) commands.`, + ); // The put method is used to fully refresh all commands in the guild with the current set - const data = await rest.put(Routes.applicationGuildCommands(process.env.CLIENT_ID ?? '', process.env.SERVER_ID ?? ''), { - body: commands, - }); + const data = await rest.put( + Routes.applicationCommands(process.env.CLIENT_ID ?? ''), + { + body: commands, + }, + ); let log = ''; if (Array.isArray(data)) log = data.length + ' ';