-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
72 lines (61 loc) · 1.6 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
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
import {
Client,
GatewayIntentBits,
Partials,
Events,
InteractionType,
} from 'discord.js'
import {
loadCommandsInteraction,
refreshCommands,
} from './src/components/LoadCommands.js'
import { loadEvents } from './src/components/loadEvents.js'
import { logMessage, logError } from './src/libs/logger.js'
import './src/config/env/env.js'
const main = async () => {
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildIntegrations,
],
partials: [
Partials.Channel,
Partials.Reaction,
Partials.Message,
Partials.GuildMember,
],
})
client.on(Events.ClientReady, async (): Promise<void> => {
if (client.user !== null) {
logMessage(`Logged in as ${client.user.tag}!`)
await refreshCommands(client)
}
})
client.on(
Events.InteractionCreate,
async (interaction): Promise<void> => {
switch (interaction.type) {
case InteractionType.ApplicationCommand:
await loadCommandsInteraction(client, interaction)
break
default:
logError(`Unknown interaction type | ${interaction.type}`)
break
}
},
)
loadEvents(client)
client.login(process.env.DISCORD_TOKEN).then().catch()
}
main()
.then()
.catch((err) => {
throw err
})