-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
97 lines (85 loc) · 2.09 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import * as fs from 'fs'
import { Collection, GatewayIntentBits, Partials } from 'discord.js'
import i18next from 'i18next'
import Backend from 'i18next-fs-backend'
import ids from './private/ids.json'
import sensitive from './private/sensitive.json'
import settings from './private/settings.json'
import { DiscordClient } from './types/customTypes'
const backend = new Backend({
loadPath: 'locales/{{lng}}/{{ns}}.json',
})
i18next.use(backend).init({
lng: 'en-US',
fallbackLng: ['en-US', 'de'],
preload: ['en-US', 'de'],
load: 'currentOnly',
ns: ['translation'],
defaultNS: 'translation',
debug: true,
backend: {
loadPath: 'locales/{{lng}}.json',
},
initImmediate: false,
})
/**
* Create instance of {@link DiscordClient}.
*/
const client: DiscordClient = new DiscordClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
})
/**
* Set {@link DiscordClient} interactions to new {@link Collection}
*/
client.interactions = new Collection()
/**
* Set config.
*/
client.config = {
settings,
sensitive,
ids,
}
/**
* Login with botToken.
*/
client.login(client.config.sensitive.botToken)
/**
* Load and run events.
*/
fs.readdir('./events/', (err, files) => {
/**
* Log errors.
*/
if (err) return console.log(err)
/**
* Loop through all event files.
*/
return files.forEach(file => {
/**
* Path of event file.
*/
const eventFunc = require(`./events/${file}`)
/**
* Name of event.
*/
const eventName = file.split('.')[0]
console.log(`Successfully loaded event ${eventName}`)
/**
* Run events when triggered.
*/
client.on(eventName, (...args) => eventFunc.run(client, ...args))
})
})