-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.ts
More file actions
28 lines (21 loc) · 769 Bytes
/
bot.ts
File metadata and controls
28 lines (21 loc) · 769 Bytes
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
import {readdirSync} from 'fs';
import {REST} from '@discordjs/rest';
import {Client, Intents} from 'discord.js';
import {Routes} from 'discord-api-types/v9';
const bot = new Client({
intents: [Intents.FLAGS.GUILDS]
});
const commandFiles = readdirSync('./commands').filter(file => file.endsWith('.ts'));
const commands: any = [];
const rest = new REST({ version: '9' }).setToken(process.env.BOT_TOKEN!);
commandFiles.forEach((file) => {
const commandData = require(`./commands/${file}`).default;
commands.push(commandData.data);
});
bot.on('ready', async () => {
await rest.put(Routes.applicationGuildCommands('912348320935084052', '789525430209085440'), {
body: commands
});
});
bot.login(process.env.BOT_TOKEN);
export default bot;