Skip to content

Commit

Permalink
manager/ready: Fix slash commands REST upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosszzz committed Oct 7, 2024
1 parent 1a4fe99 commit 395d491
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ declare module "discord.js" {
export type Config = {
TOKEN: string;
DEVTOKEN: string;
CLIENT_ID: string;
CLIENT_ID_DEV: string;
MAX_PLAYLIST_SIZE: number;
SOUNDCLOUD_CLIENT_ID: string;
SPOTIFY_SECRET_ID: string;
Expand Down
2 changes: 2 additions & 0 deletions src/components/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Config } from "@common";
export const config: Config = {
TOKEN: process.env.TOKEN || "",
DEVTOKEN: process.env.DEVTOKEN || "",
CLIENT_ID: process.env.CLIENT_ID || "",
CLIENT_ID_DEV: process.env.CLIENT_ID_DEV || "",
SOUNDCLOUD_CLIENT_ID: process.env.SOUNDCLOUD_CLIENT_ID || "",
MAX_PLAYLIST_SIZE: Number(process.env.MAX_PLAYLIST_SIZE) || Number(20),
SPOTIFY_CLIENT_ID: process.env.SPOTIFY_CLIENT_ID || "",
Expand Down
3 changes: 2 additions & 1 deletion src/manager/modules/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { commands as infoCmds } from "commands/info/index.js";
import { commands as utilCmds } from "commands/utility/index.js";
import type { Bot } from "@components/Bot";
import chalk from "chalk";
import { config } from "@components/config";

export async function ready(client: Bot): Promise<void> {
await new Promise<void>(async (resolve) => {
Expand All @@ -25,7 +26,7 @@ export async function ready(client: Bot): Promise<void> {
if (client.debug) Logger.info({ type: "DEVELOPMENT READY/CMDS", msg: `${commands[i].data.name} has been loaded.` });
};

await client.rest.put(Routes.applicationCommands(client.user!.id), {
await client.rest.put(Routes.applicationCommands(client.debug ? config.CLIENT_ID_DEV : config.CLIENT_ID), {
body: commands.map(cmd => cmd.data.toJSON())
});
Logger.log({ type: "READY/CMDS", msg: `Registered ${chalk.blueBright(commands.length)} commands on Discord.` });
Expand Down

0 comments on commit 395d491

Please sign in to comment.