From 12b4f44e1c2a69fc294cc2275617d1d16957109e Mon Sep 17 00:00:00 2001 From: Sebastian Pietschner Date: Wed, 12 Oct 2022 08:26:05 +0000 Subject: [PATCH] fix deploy --- src/classes/Commands.ts | 24 ++++++------------------ src/deploy-commands.ts | 1 + src/remove-commands.ts | 1 + src/scripts/deploy.ts | 3 ++- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/classes/Commands.ts b/src/classes/Commands.ts index 6426ec5..833bbe4 100644 --- a/src/classes/Commands.ts +++ b/src/classes/Commands.ts @@ -5,19 +5,11 @@ import { ButtonStyle, CacheType, ChatInputCommandInteraction, - RESTPostAPIApplicationCommandsJSONBody, - SlashCommandBuilder, - SlashCommandSubcommandsOnlyBuilder, } from 'discord.js'; import { Service } from 'typedi'; import type Command from './Command'; import ConditionError from './ConditionError'; -type SlashCommandBuilderTypes = - | SlashCommandBuilder - | SlashCommandSubcommandsOnlyBuilder - | Omit; - // Report error button const errorRow = new ActionRowBuilder().addComponents([ new ButtonBuilder() @@ -28,10 +20,11 @@ const errorRow = new ActionRowBuilder().addComponents([ @Service() export default class Commands { - constructor(private commands: Record = {}) {} + private commands: Record = {}; public register(command: Command): void { this.commands[command.name] = command; + // console.log(this.commands); } public registerMany(commands: Command[]): void { @@ -42,11 +35,11 @@ export default class Commands { return this.commands[name]; } - public get count(): number { + public count(): number { return Object.keys(this.commands).length; } - public get all(): Command[] { + public all(): Command[] { return Object.values(this.commands); } @@ -54,13 +47,8 @@ export default class Commands { return Object.keys(this.commands); } - public get data(): SlashCommandBuilderTypes[] { - return this.all.map((command) => command.data); - } - - public get json(): RESTPostAPIApplicationCommandsJSONBody[] { - return this.all.map((command) => command.data.toJSON()); - } + public data = () => + Object.values(this.commands).map((command) => command.data.toJSON()); public run = async ( interaction: ChatInputCommandInteraction diff --git a/src/deploy-commands.ts b/src/deploy-commands.ts index 8ecb8ea..67f6a79 100644 --- a/src/deploy-commands.ts +++ b/src/deploy-commands.ts @@ -1,3 +1,4 @@ +import 'reflect-metadata'; import { config } from 'dotenv'; import deploy from './scripts/deploy'; diff --git a/src/remove-commands.ts b/src/remove-commands.ts index 3e96c04..ce42f71 100644 --- a/src/remove-commands.ts +++ b/src/remove-commands.ts @@ -1,3 +1,4 @@ +import 'reflect-metadata'; import { config } from 'dotenv'; import remove from './scripts/remove'; diff --git a/src/scripts/deploy.ts b/src/scripts/deploy.ts index 6a55853..31e85d0 100644 --- a/src/scripts/deploy.ts +++ b/src/scripts/deploy.ts @@ -17,7 +17,8 @@ export default async () => { registerCommands(); const commands = Container.get(Commands); - const { json: commandData } = commands; + const commandData = commands.data(); + // console.log({ commandData }); const rest = new REST({ version: '10' }).setToken(TOKEN);