This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
forked from MarcinK50/HRejterzy-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (44 loc) · 1.72 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
const fs = require('fs');
global.Discord = require('discord.js-light');
global.config = require('./config.json');
const cooldown = new Map();
global.client = new Discord.Client({
messageCacheLifetime: 10,
messageCacheMaxSize: 1,
messageSweepInterval: 10,
disableEveryone: true,
fetchAllMembers: false,
shards: "auto",
cacheGuilds: true,
cacheChannels: false,
cacheOverwrites: true,
cacheRoles: false,
cacheEmojis: false,
cachePresences: false,
ws: {
intents: ["GUILD_MESSAGES"]
}
});
client.commands = new Map();
const updateActivity = () => client.user.setActivity("hrhelp | Error: Object reference is not set to an instance of an object.");
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.on('ready', () => {
console.log('Rajesh is ready to help you with all of your issues!');
updateActivity();
setInterval(updateActivity, 1000 * 60 * 5);
});
client.on('message', message => {
if (!message.content.toLowerCase().startsWith(config.prefix) || message.author.bot || !message.guild) return;
const args = message.content.slice(config.prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
const cmd = client.commands.get(command);
if (!cmd) return;
if (cooldown.get(message.channel.id) > Date.now()) return message.channel.send(`Nie tak szybko! Komend na tym kanale można używać co ${config.cooldownTime / 1000} sekundy!`);
cmd.run(message, args);
cooldown.set(message.channel.id, Date.now() + config.cooldownTime);
});
client.login(config.token);