-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (50 loc) · 1.46 KB
/
index.js
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
const path = require("path");
const { SlashCreator, GatewayServer } = require("slash-create");
const { Client, GatewayIntentBits, ActivityType } = require("discord.js");
const dotenv = require("dotenv");
dotenv.config();
const client = new Client({
intents: [GatewayIntentBits.Guilds],
allowedMentions: { parse: [] }
});
const creator = new SlashCreator({
applicationID: process.env.DISCORD_CLIENT_ID,
publicKey: process.env.DISCORD_CLIENT_PUBKEY,
token: process.env.DISCORD_CLIENT_TOKEN,
client
});
function updatePresence() {
client.user.setActivity(":3", { // set bot activity
type: ActivityType.Watching,
});
}
client.on("ready", () => { // when bot client is ready
if (process.env.NODE_ENV != "production") { // if not in production
client.user.setActivity("development", {
type: ActivityType.Listening,
});
console.log("⚠️ Development mode!");
console.log(`Logged in as ${client.user.tag}`);
return;
}
console.log(`Logging in as ${client.user.tag}`);
updatePresence();
console.log("Ready!");
setInterval(() => {
updatePresence();
}, 60000);
});
(async () => {
creator.withServer(
new GatewayServer(
(handler) => client.ws.on('INTERACTION_CREATE', handler)
)
);
await creator.registerCommandsIn(path.join(__dirname, 'commands'));
await creator.syncCommands({ deleteCommands: true });
})();
client.login(process.env.DISCORD_CLIENT_TOKEN);
module.exports = {
client,
creator,
};