-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbot.js
More file actions
61 lines (50 loc) · 1.81 KB
/
bot.js
File metadata and controls
61 lines (50 loc) · 1.81 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
const { Client, GatewayIntentBits, Collection, ActivityType} = require('discord.js')
require('dotenv').config()
const config = require('./config.json')
const { join } = require('path')
const { setInterval } = require('timers')
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates]})
client.commands = new Collection()
client.selectMenus = new Collection()
client.buttons = new Collection()
client.languages = require('i18n')
client.languages.configure({
locales: ['en', 'es'],
directory: join(__dirname, "locales"),
defaultLocale: config.defaultLanguage,
retryInDefaultLocale: true,
objectNotation: true,
register: global,
logWarnFn: function (msg) {
console.log('WARN' + msg)
},
logErrorFn: function (msg) {
console.log('ERROR' + msg)
},
missingKeyFn: function (locale, value) {
return value
},
mustacheConfig: {
tags: ["{{", "}}"],
disable: false
}
})
setInterval(() => {
updateStatus()
}, 60000)
async function updateStatus() {
const promises = [
client.shard.fetchClientValues('guilds.cache.size'),
client.shard.broadcastEval(c => c.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0))
]
Promise.all(promises).then(results => {
const guildNum = results[0].reduce((acc, guildCount) => acc + guildCount, 0)
const memberNum = results[1].reduce((acc, memberCount) => acc + memberCount, 0)
client.user.setActivity(`Servidores: ${guildNum} Miembros: ${memberNum}`, { type: ActivityType.Listening})
}).catch(console.error)
}
require("./handlers/events.js")(client);
require("./handlers/commands.js")(client);
require("./handlers/selectmenus.js")(client);
require('./handlers/buttons.js')(client)
client.login(process.env.token);