1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 01:21:56 +00:00
musix-oss/index.js
2020-06-29 20:48:42 +03:00

40 lines
1.0 KiB
JavaScript

const config = require("./src/struct/config/config.js");
const DiscordWebhook = require("discord-webhook-node");
if (config.devMode) {
console.log("- dev mode- ");
config.token = config.devToken;
config.shards = 1;
}
const {
ShardingManager
} = require("discord.js");
const manager = new ShardingManager("./src/bot.js", {
token: config.token,
respawn: config.respawn,
totalShards: config.shards,
});
console.log("- Launching shards -");
manager.spawn(config.shards, config.shardDelay, config.shardTimeout);
manager.on("shardCreate", (shard) =>
console.log(`- Launched shard ${shard.id} -`)
);
const webhookClient = new DiscordWebhook.Webhook(config.webhookUrl);
const oldConsole = {};
oldConsole.log = console.log;
console.log = function (arg) {
oldConsole.log(arg);
if (!config.devMode && arg)
webhookClient.send(JSON.stringify(arg));
};
oldConsole.error = console.error;
console.error = function (arg) {
oldConsole.error(arg);
if (!config.devMode && arg)
webhookClient.send(JSON.stringify(arg));
};