Zheoni / Discord-Overwatch-Leaderboard

Discord bot to display an Overwatch ranked leaderboard in a server
MIT License
1 stars 4 forks source link

Errors with database foreign keys of leaderboards to accounts #9

Open achselhaar opened 3 years ago

achselhaar commented 3 years ago

Hello my Friend,

I've been getting an error message since August and I don't know how to fix it :(

https://ibb.co/pv9ZN83

greetings from Germany :)

Zheoni commented 3 years ago

Hi! ✋

Sorry to hear that the bot is not working, I'm not using it at the moment so I did not notice it. Probably the API changed something or stopped working and needs to be updated. However, could you give a more detailed information about the error? What message is it showing? When does it happens?

achselhaar commented 3 years ago

Hey, thanks for answer :) after node index.js

Overwatch Leaderboard is online on 1 server(s)! Updating player's data Showing all leaderboards (node:16364) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'rankTANK' of null at Object.showLeaderboard (G:\Roleq\modules\leaderboard.js:104:24) at (node:16364) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:16364) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Zheoni commented 3 years ago

So, I don't have this problem if I run the bot. However I'm pretty sure that the problem is that the database has gotten wrong data somehow and cannot retrieve information about a player or a group of players.

Quick solution

To fix this the easy way you can run node dbInit --force. THIS WILL REMOVE ALL PLAYERS AND YOU WILL NEED TO ADD THEM AGAIN.

Another solution is to run this SQL code over that database file. With sqlite3 database.sqlite in the command line you can acces the SQLite promt and write the following.

DELETE FROM accounts WHERE battleTag NOT IN (SELECT DISTINCT battleTag FROM leaderboards);
DELETE FROM leaderboards WHERE battleTag NOT IN (SELECT DISTINCT battleTag FROM accounts);

This will remove the players that are making the bot crash or printing error messages. You will probably need to install the sqlite3 command somehow, depends on the system but google should help.

One of those two should make the bot work again, but you will potentially have to add all or some players again.

Long term solution

Of course this should not happen, the database should not corrupt and it is a bug. I will keep this issue open and this will be fixed in a future update of the bot.

achselhaar commented 3 years ago

Nice! Thank u 👍 Its work's :)