-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
46 lines (42 loc) · 1.24 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {
Client,
token,
GatewayIntents,
SlashCommandOption,
SlashCommandHandlerCallback,
} from './deps.ts';
const bot = new Client();
bot.on('ready', async () => {
console.log("Started bot");
(await (await bot.slash.commands.all()).array()).forEach(cmd=>{
bot.slash.commands.delete(cmd.id)
})
for await (const file of Deno.readDir('./commands')) {
if (!file.isFile || !file.name.endsWith('.ts')) continue;
const command: CommandData = (await import('./commands/' + file.name))
.data;
bot.slash.commands.create({
name: command.name,
options: command.options,
description: command.description,
}, '849844854884007966');
bot.slash.handle(command.name, command.execute);
if(command.aliases?.length == null) return;
for (const alias of command.aliases) {
bot.slash.commands.create({
name: alias,
options: command.options,
description: command.description,
}, '849844854884007966');
bot.slash.handle(alias, command.execute);
}
}
});
bot.connect(token || Deno.env.get('token'), [GatewayIntents.GUILDS, GatewayIntents.GUILD_MESSAGES]);
interface CommandData {
name: string;
description: string;
aliases?: string;
options?: SlashCommandOption[];
execute: SlashCommandHandlerCallback;
}