-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
74 lines (62 loc) · 1.97 KB
/
index.ts
File metadata and controls
74 lines (62 loc) · 1.97 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import "reflect-metadata";
import 'dotenv/config';
import { Intents, Interaction, Message } from "discord.js";
import { Client } from "discordx";
import { dirname, importx } from "@discordx/importer";
import AWS from "aws-sdk";
export const client = new Client({
simpleCommand: {
prefix: "!",
},
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_VOICE_STATES,
],
// If you only want to use global commands only, comment this line
botGuilds: [(client) => client.guilds.cache.map((guild) => guild.id)],
});
client.once("ready", async () => {
// make sure all guilds are in cache
await client.guilds.fetch();
// init all application commands
await client.initApplicationCommands({
guild: { log: true },
global: { log: true },
});
// init permissions; enabled log to see changes
await client.initApplicationPermissions(true);
// uncomment this line to clear all guild commands,
// useful when moving to global commands from guild commands
// await client.clearApplicationCommands(
// ...client.guilds.cache.map((g) => g.id)
// );
console.log("Bot started");
});
client.on("interactionCreate", (interaction: Interaction) => {
client.executeInteraction(interaction);
});
client.on("messageCreate", (message: Message) => {
client.executeCommand(message);
});
async function run() {
// with cjs
// await importx(__dirname + "/{events,commands}/**/*.{ts,js}");
// with ems
await importx(
dirname(import.meta.url) + "/{events,commands,api}/**/*.{ts,js}"
);
// let's start the bot
if (!process.env.BOT_TOKEN) {
throw Error("Could not find BOT_TOKEN in your environment");
}
await client.login(process.env.BOT_TOKEN); // provide your bot token
}
AWS.config.update({
region: process.env.AWS_DEFAULT_REGION,
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
})
run();