|
1 |
| -const fs = require("fs"); |
2 |
| -const Discord = require("discord.js"); |
3 |
| -const client = new Discord.Client(); |
| 1 | +const { ShardingManager } = require('discord.js'); |
4 | 2 | const config = require("./config.json");
|
5 |
| -const { prefix } = require("./config.json"); |
6 |
| -client.commands = new Discord.Collection(); |
| 3 | +const manager = new ShardingManager('./bot.js', { token: config.token }); |
7 | 4 |
|
8 |
| - |
9 |
| - |
10 |
| - |
11 |
| - |
12 |
| -const commandFiles = fs |
13 |
| - .readdirSync("./commands") |
14 |
| - .filter((file) => file.endsWith(".js")); |
15 |
| - |
16 |
| - |
17 |
| -client.once("ready", () => { |
18 |
| - console.log("My Body is ready."); |
19 |
| -}); |
20 |
| - |
21 |
| -for (const file of commandFiles) { |
22 |
| - const command = require(`./commands/${file}`); |
23 |
| - |
24 |
| - // set a new item in the Collection |
25 |
| - // with the key as the command name and the value as the exported module |
26 |
| - client.commands.set(command.name, command); |
27 |
| -} |
28 |
| - |
29 |
| -client.on("message", (message) => { |
30 |
| - function clean(text) { |
31 |
| - if (typeof text === "string") |
32 |
| - return text |
33 |
| - .replace(/@/g, "" + String.fromCharCode(8203)) |
34 |
| - .replace(/@/g, "@" + String.fromCharCode(8203)); |
35 |
| - else return text; |
36 |
| - } |
37 |
| - if (!message.content.startsWith(prefix) || message.author.bot) return; |
38 |
| - |
39 |
| - const args = message.content.slice(prefix.length).trim().split(/ +/); |
40 |
| - const command = args.shift().toLowerCase(); |
41 |
| - if (!client.commands.has(command)) return; |
42 |
| - |
43 |
| - try { |
44 |
| - client.commands.get(command).execute(message, args, client); |
45 |
| - } catch (error) { |
46 |
| - console.error(error); |
47 |
| - message.channel.send( |
48 |
| - `\`An unexpected error has occured! Please try again later! Please report this to @BoredFish#4269. More technical details:\` \`\`\`xl\n${clean( |
49 |
| - error |
50 |
| - )}\n\`\`\`` |
51 |
| - ); |
52 |
| - } |
53 |
| -}); |
54 |
| - |
55 |
| -client.login(config.token); |
| 5 | +manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`)); |
| 6 | +manager.spawn(); |
0 commit comments