I'm uncertain if this is an issue with the bot itself or my setup.
After the bot has been started, all the commands are fully functional. However, after a period of inactivity (seems to be a few hours), the bot seems to lose connection to the server. The loss of connection is not noticed until another command is sent to the bot, at which time the bot will respond with the following error:
There was an error trying to execute that command!
This is the output printed to the console:
Error: Can't add new command when connection is in closed state
at Connection._addCommandClosedState (/opt/warcraft/AzerothCoreDiscordBot/node_modules/mysql2/lib/connection.js:148:17)
at Connection.query (/opt/warcraft/AzerothCoreDiscordBot/node_modules/mysql2/lib/connection.js:546:17)
at Object.execute (/opt/warcraft/AzerothCoreDiscordBot/commands/online.js:14:16)
at Client.<anonymous> (/opt/warcraft/AzerothCoreDiscordBot/server.js:72:65)
at Client.emit (node:events:527:28)
at MessageCreateAction.handle (/opt/warcraft/AzerothCoreDiscordBot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/opt/warcraft/AzerothCoreDiscordBot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/opt/warcraft/AzerothCoreDiscordBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/opt/warcraft/AzerothCoreDiscordBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/opt/warcraft/AzerothCoreDiscordBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10) {
fatal: true
}
The azerothcore server itself is a docker installation. My config.js is as follows:
module.exports = {
token: "<redacted>",
prefix: "!",
statusMessage: "with my 25 characters!",
color: "#0000FF",
databaseHost: '127.0.0.1',
databaseUser : '<redacted>',
databasePassword : '<redacted>',
soapPort: 7878,
soapHostname: "127.0.0.1",
soapAuth: "<redacted>"
}
One other note is that the soapAuth user is the GM account I use when I need to perform GM functions. Would logging into that account cause the bot to disconnect, and is it recommended for the bot to have a dedicated GM account through which to authenticate with the server?