aboutsummaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-01-09 13:04:14 +0100
committerMinteck <contact@minteck.org>2022-01-09 13:04:14 +0100
commitdc65563df84d80bcc0970febef6a5f9a7759bdcb (patch)
tree683adf13430bce48c23e6928a3a2eb0b5614094a /index.js
parentad5950fb36d71b0f522ac3dab80983212cafee44 (diff)
downloadponyfind-dc65563df84d80bcc0970febef6a5f9a7759bdcb.tar.gz
ponyfind-dc65563df84d80bcc0970febef6a5f9a7759bdcb.tar.bz2
ponyfind-dc65563df84d80bcc0970febef6a5f9a7759bdcb.zip
smol update
Diffstat (limited to 'index.js')
-rw-r--r--index.js99
1 files changed, 6 insertions, 93 deletions
diff --git a/index.js b/index.js
index c877049..8cf19a2 100644
--- a/index.js
+++ b/index.js
@@ -1,96 +1,9 @@
-// Stable: https://discord.com/oauth2/authorize?client_id=928695013083316295&scope=bot%20applications.commands&permissions=0
-// Beta: https://discord.com/oauth2/authorize?client_id=929057534491361341&scope=bot%20applications.commands&permissions=0
+global.channel = (require('fs').existsSync("./beta") ? "beta" : "stable");
+const { ShardingManager } = require('discord.js');
+const fs = require("fs");
-console.log("Channel: " + (typeof process.argv[2] !== "undefined" ? "beta" : "stable"));
-global.channel = (typeof process.argv[2] !== "undefined" ? "beta" : "stable");
+const manager = new ShardingManager('./bot.js', { token: fs.readFileSync("./config/token." + (require('fs').existsSync("./beta") ? "beta" : "stable") + ".txt").toString() });
-const fs = require('fs');
-const { REST } = require('@discordjs/rest');
-const { Routes } = require('discord-api-types/v9');
+manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
-if (!fs.existsSync("./user/userdata.json")) fs.writeFileSync("./user/userdata.json", "{}");
-if (!fs.existsSync("./user/servers.json")) fs.writeFileSync("./user/servers.json", "{}");
-if (!fs.existsSync("./reports")) fs.mkdirSync("./reports");
-
-const rest = new REST({ version: '9' }).setToken(fs.readFileSync("./config/token." + (typeof process.argv[2] !== "undefined" ? "beta" : "stable") + ".txt").toString());
-const { Client, Intents, MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');
-global.client = new Client({ intents: [Intents.FLAGS.GUILDS] });
-
-const commandHandler = require('./handler/command');
-const buttonHandler = require('./handler/button');
-const menuHandler = require('./handler/menu');
-const errorHandler = require('./handler/errors');
-
-global.langs = JSON.parse(fs.readFileSync("./user/userdata.json"));
-global.servers = JSON.parse(fs.readFileSync("./user/servers.json"));
-
-global.l = (en, fr, id, gid) => {
- if (typeof servers[gid] !== "undefined") {
- if (servers[gid] === "fr") {
- return fr;
- } else {
- return en;
- }
- } else {
- if (langs[id] === "fr") {
- return fr;
- } else {
- return en;
- }
- }
-}
-
-const commands = require('./modules/registers');
-
-client.on('ready', async () => {
- console.log(`Logged in as ${client.user.tag}!`);
- for (let guild of client.guilds.cache.map(g => g.id)) {
- try {
- console.log('Started refreshing application (/) commands for guild ' + guild + '.');
-
- await rest.put(
- Routes.applicationGuildCommands(fs.readFileSync("./config/client." + (typeof process.argv[2] !== "undefined" ? "beta" : "stable") + ".txt").toString(), guild),
- { body: commands },
- );
-
- console.log('Successfully reloaded application (/) commands for guild ' + guild + '.');
- } catch (error) {
- console.error(error);
- }
- }
-});
-
-client.on('guildCreate', async () => {
- for (let guild of client.guilds.cache.map(g => g.id)) {
- try {
- console.log('Started refreshing application (/) commands for guild ' + guild + '.');
-
- await rest.put(
- Routes.applicationGuildCommands(fs.readFileSync("./config/client." + (typeof process.argv[2] !== "undefined" ? "beta" : "stable") + ".txt").toString(), guild),
- { body: commands },
- );
-
- console.log('Successfully reloaded application (/) commands for guild ' + guild + '.');
- } catch (error) {
- console.error(error);
- }
- }
-})
-
-client.on('interactionCreate', async interaction => {
- try {
- if (interaction.isCommand()) {
- await commandHandler(interaction);
- } else if (interaction.isButton()) {
- await buttonHandler(interaction);
- } else if (interaction.isSelectMenu()) {
- await menuHandler(interaction);
- } else {
- throw new Error("Interaction type not supported")
- }
- } catch (e) {
- errorHandler(interaction, e)
- }
-});
-
-client.login(fs.readFileSync("./config/token." + (typeof process.argv[2] !== "undefined" ? "beta" : "stable") + ".txt").toString()); \ No newline at end of file
+manager.spawn(); \ No newline at end of file