Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
fix deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasptsch committed Oct 12, 2022
1 parent 1212fef commit 12b4f44
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
24 changes: 6 additions & 18 deletions src/classes/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;

// Report error button
const errorRow = new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder()
Expand All @@ -28,10 +20,11 @@ const errorRow = new ActionRowBuilder<ButtonBuilder>().addComponents([

@Service()
export default class Commands {
constructor(private commands: Record<string, Command> = {}) {}
private commands: Record<string, Command> = {};

public register(command: Command): void {
this.commands[command.name] = command;
// console.log(this.commands);
}

public registerMany(commands: Command[]): void {
Expand All @@ -42,25 +35,20 @@ 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);
}

public get names(): string[] {
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<CacheType>
Expand Down
1 change: 1 addition & 0 deletions src/deploy-commands.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'reflect-metadata';
import { config } from 'dotenv';
import deploy from './scripts/deploy';

Expand Down
1 change: 1 addition & 0 deletions src/remove-commands.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'reflect-metadata';
import { config } from 'dotenv';
import remove from './scripts/remove';

Expand Down
3 changes: 2 additions & 1 deletion src/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 12b4f44

Please sign in to comment.