Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 597598c

Browse files
committed
back to the good old days
1 parent 30a5684 commit 597598c

File tree

6 files changed

+22
-58
lines changed

6 files changed

+22
-58
lines changed

src/commands/main/data.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction } from "
22
import { KOGBot } from "index.js";
33
import knex, { Knex } from "knex";
44
class GetDataCommand implements SlashCommand {
5-
name = "data";
6-
description = "Database command for KOG.";
7-
subcommands = [];
8-
parameters = [];
5+
data = new SlashCommandBuilder()
6+
.setName('data')
7+
.setDescription('Data stuff.');
98
dev = true;
109
kogBot: KOGBot;
1110

src/commands/main/log.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { EmbedBuilder, ChatInputCommandInteraction, GuildMemberRoleManager, Colors } from 'discord.js';
1+
import { EmbedBuilder, ChatInputCommandInteraction, GuildMemberRoleManager, Colors, SlashCommandBuilder } from 'discord.js';
22
import { KOGBot } from '../../index.js';
33

44
class LogEventCommand implements SlashCommand {
5-
name = 'log';
6-
description = 'Logs official events for KOG.';
7-
subcommands = [];
8-
parameters = [];
5+
data = new SlashCommandBuilder()
6+
.setName('logevent')
7+
.setDescription('Log an event.')
98
dev = true;
109
kogBot: KOGBot;
1110

src/commands/misc/kill.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
import { EmbedBuilder, ChatInputCommandInteraction, SlashCommandBuilder, SlashCommandUserOption } from "discord.js";
1+
import { EmbedBuilder, ChatInputCommandInteraction, SlashCommandBuilder, SlashCommandUserOption, SlashCommandSubcommandBuilder } from "discord.js";
22
import { KOGBot } from "../../index.js";
33

44
class KillCommand implements SlashCommand {
5-
name = 'kill';
6-
description = 'Kill a user (in messages).';
7-
subcommands = [];
8-
parameters = [
9-
new SlashCommandUserOption()
10-
.setName('user')
11-
.setDescription('The user to kill')
12-
.setRequired(true)
13-
];
5+
data = new SlashCommandBuilder()
6+
.setName('kill')
7+
.setDescription('Kill a user.')
148
dev = true;
159
kogBot: KOGBot;
1610

src/commands/misc/ping.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { ChatInputCommandInteraction, EmbedBuilder, Colors } from "discord.js";
1+
import { ChatInputCommandInteraction, EmbedBuilder, Colors, SlashCommandBuilder } from "discord.js";
22
import { KOGBot } from "../../index.js"; // Adjust the path if necessary
33

44
class PingCommand implements SlashCommand {
5-
name = "ping";
6-
description = "Checks the bot's latency.";
7-
subcommands = [];
8-
parameters = [];
5+
data = new SlashCommandBuilder()
6+
.setName('ping')
7+
.setDescription('Check the bot\'s latency.');
98
dev = true;
109
kogBot: KOGBot;
1110

src/index.ts

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Client, IntentsBitField, REST, SlashCommandBuilder, Routes, SlashCommandSubcommandBuilder } from "discord.js";
1+
import { Client, IntentsBitField, REST, SlashCommandBuilder, Routes, SlashCommandSubcommandBuilder, RESTPostAPIApplicationCommandsJSONBody } from "discord.js";
22
import fs from 'fs';
33
import knex, { Knex } from "knex";
44
import toml from 'toml';
@@ -76,7 +76,7 @@ class DBot extends Client {
7676
}
7777

7878
commands = {
79-
list: [] as any[],
79+
list: [] as RESTPostAPIApplicationCommandsJSONBody[],
8080

8181
parse: async () => {
8282
const folderPath = join(__dirname, 'commands');
@@ -85,38 +85,14 @@ class DBot extends Client {
8585

8686
for (const category of commandCategories) {
8787
const commandsPath = join(folderPath, category);
88-
const commandFiles = readdirSync(commandsPath).filter(file => file.endsWith('.js'));
88+
const commandFiles = readdirSync(commandsPath);
8989

9090
for (const file of commandFiles) {
9191
const filePath = join(commandsPath, file);
9292
const commandClass = (await import(`file://${filePath}`)).default;
9393
const command: SlashCommand = new commandClass(this.kogBot);
94-
const slashCommand = new SlashCommandBuilder();
9594

96-
slashCommand.setName(command.name);
97-
slashCommand.setDescription(command.description);
98-
99-
for (const parameter of command.parameters) {
100-
slashCommand.options.push(parameter);
101-
}
102-
103-
if (command.subcommands.length > 0) {
104-
for (const subcommand of command.subcommands) {
105-
const sub = new SlashCommandSubcommandBuilder()
106-
.setName(subcommand.name)
107-
.setDescription(subcommand.description);
108-
for (const parameter of command.parameters) {
109-
sub.options.push(parameter);
110-
}
111-
slashCommand.addSubcommand(sub);
112-
}
113-
114-
}
115-
116-
commands.push({
117-
builder: slashCommand,
118-
instance: command
119-
});
95+
commands.push(command.data.toJSON());
12096
}
12197
}
12298
return commands;
@@ -131,7 +107,7 @@ class DBot extends Client {
131107
console.log(`Deploying ${this.commands.list.length} commands...`);
132108
await this.REST.put(
133109
Routes.applicationCommands(this.kogBot.environment.discord.client_id),
134-
{ body: this.commands.list.map(cmd => cmd.builder) }
110+
{ body: [] }
135111
);
136112
}
137113
}

src/types/main.d.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApplicationCommandOptionBase, ChatInputCommandInteraction } from "discord.js";
1+
import { ApplicationCommandOptionBase, ChatInputCommandInteraction, SlashCommandBuilder, SlashCommandSubcommandBuilder } from "discord.js";
22
import { KOGBot } from "index.ts";
33

44
global {
@@ -15,10 +15,7 @@ global {
1515
}
1616

1717
declare interface SlashCommand {
18-
name: string;
19-
description: string;
20-
subcommands: Array<SlashCommand>;
21-
parameters: Array<ApplicationCommandOptionBase>;
18+
data: SlashCommandBuilder;
2219
dev?: boolean;
2320
kogBot: KOGBot;
2421

0 commit comments

Comments
 (0)