1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-14 03:30:18 +00:00
musix-oss/index.js

40 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-04-21 11:29:36 +00:00
const config = require("./src/struct/config/config.js");
2020-06-16 18:51:11 +00:00
const DiscordWebhook = require("discord-webhook-node");
2020-03-13 20:31:04 +00:00
if (config.devMode) {
2020-04-20 16:56:23 +00:00
console.log("- dev mode- ");
config.token = config.devToken;
config.shards = 1;
2020-03-13 20:31:04 +00:00
}
const {
ShardingManager
} = require("discord.js");
2020-04-20 16:56:23 +00:00
const manager = new ShardingManager("./src/bot.js", {
token: config.token,
respawn: config.respawn,
totalShards: config.shards,
2020-04-19 17:00:16 +00:00
});
2020-03-13 20:31:04 +00:00
2020-04-20 16:56:23 +00:00
console.log("- Launching shards -");
2020-03-13 20:31:04 +00:00
manager.spawn(config.shards, config.shardDelay, config.shardTimeout);
2020-04-20 16:56:23 +00:00
manager.on("shardCreate", (shard) =>
console.log(`- Launched shard ${shard.id} -`)
2020-06-16 18:51:11 +00:00
);
const webhookClient = new DiscordWebhook.Webhook(config.webhookUrl);
const oldConsole = {};
oldConsole.log = console.log;
console.log = function (arg) {
oldConsole.log(arg);
2020-06-29 17:48:42 +00:00
if (!config.devMode && arg)
webhookClient.send(JSON.stringify(arg));
2020-06-16 18:51:11 +00:00
};
oldConsole.error = console.error;
console.error = function (arg) {
oldConsole.error(arg);
2020-06-29 17:48:42 +00:00
if (!config.devMode && arg)
webhookClient.send(JSON.stringify(arg));
};