Я столкнулся с данной проблемой ещё давно, но до сих пор не могу её решить. В чём заключается проблема:Бот со временем сам выключается, не зависит от нагрузки на него и сколько он был включённым, консоль при этом открыта, никаких ошибок нет, просто он тупо выключается, но если в консоли нажать ctrl + `, то с шансом 50% он снова включится, может кто-то сталкивался с этим, как это решить ?
index.js :
const Discord = require("discord.js"); //библиотека Дискорд
const sdr = new Discord.Client({disableEveryone: true}); //имя клиент
const config = require("./config/bconfig.json"); //путь до конфига
const baseMessage = require('./Module/ModuleDatabase.js'); //база сообщений
const fs = require('fs');
const sql = require("sqlite");
const moment = require('moment');
const chalk = require('chalk');
const money = require('discord-money');
const ini = require('ini');
//Краситили
const GreenStyle = chalk.green; //Зелёный
const RedStyle = chalk.red; //Крассный
const BlueStyle = chalk.blue; //Синий
const YellowStyle = chalk.yellow; //Жёлтый
const MagentaStyle = chalk.magentaBright; //серенивый
const GrayStyle = chalk.gray; // серый
const RedBackground = chalk.bgRed // Фон красный
const mathjs = require('mathjs')
sdr.commands = new Discord.Collection();
sdr.commands1 = new Discord.Collection();
const talkedRecently = new Set();
const ErrorCheck = require('./Module/Error.js') //модуль ошибок
sdr.login(config.token);
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
sdr.on('ready', async () => {
process.on("unhandledRejection", console.error);
console.log('Я запустился!');
console.log(`
╔════════════════════════════════════════════════════════════════
║ ${GrayStyle(`• ${sdr.users.cache.size} всего участников`)}
║ ${GrayStyle(`• ${sdr.channels.cache.size} всего каналов`)}
║ ${GrayStyle(`• Бот состоит в: ${sdr.guilds.cache.size} группах`)}
║ ${GrayStyle(`• `)}
║ ${GrayStyle(`• `)}
║ ${GrayStyle(`• `)}
╚════════════════════════════════════════════════════════════════
`)
});
//модуль команд
//========================================================================
fs.readdir("./utils/", (err, files) => {
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js")
if(jsfile.length <= 0){
console.log("Не удалось найти команды.");
return;
}
jsfile.forEach((f, i) =>{
let props = require(`./utils/${f}`);
sdr.commands.set(props.help.name, props);
});
});
sdr.on("message", async message => {
if(!message.guild)
if(message.author.bot) return;
if(message.author.id == config.SudarID) return;
if(message.channel.type === "dm") return;
if(message.content.indexOf(config.prefix) !== 0) return;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1)
let commandfile = sdr.commands.get(cmd.slice(config.prefix.length));
if(commandfile) commandfile.run(sdr,message,args);
});
Я думал дело в {disableEveryone: true}, ибо его вроде убрали в 12 версии, но оказалось нет, после того как нажимаю любую кнопку и бот просыпается, я в debug получаю следующее:
[WS => Shard 0] Heartbeat acknowledged, latency of 148ms.
[WS => Shard 0] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 0] [CLOSE]
Event Code: 1000
Clean : false
Reason : No reason received
[WS => Shard 0] Clearing the heartbeat interval.
[WS => Shard 0] WS State: CLOSED
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 999
[WS => Shard 0] [CONNECT]
Gateway : wss://gateway.discord.gg/
Version : 6
Encoding : json
Compression: none
[WS => Shard 0] Setting a HELLO timeout for 20s.
[WS => Shard 0] [CONNECTED] in 240ms
Я заметил что эта проблема появляется абсолютно рандомно, если закрыть и открыть консоль то эта проблема может появится уже через минуту, а может через пару дней, я думаю это дело в интернете самом