Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot crashes on guild join request #7

Open
IdkDom opened this issue Apr 23, 2024 · 0 comments
Open

Bot crashes on guild join request #7

IdkDom opened this issue Apr 23, 2024 · 0 comments

Comments

@IdkDom
Copy link

IdkDom commented Apr 23, 2024

I was confused for the longest time why the bot kept crashing, found where the error was in the logs and started testing.

if (this.isJoinRequest(message)) {
const fs = require('fs');
let rawdata = fs.readFileSync('config.json');
let config = JSON.parse(rawdata);
if (message.includes("[VIP]") || message.includes("[VIP+]") || message.includes("[MVP]") || message.includes("[MVP+]") || message.includes("[MVP++]")) {
let user = message.split(' ')[1];
} else {
let user = message.split(' ')[0];
}

In this handler the bot does indeed work when going through the if-statement, but user being defined in the if-statement causes it to not work. What I did to fix this was putting let user = ""; before the if-statement, and then just having user = message.split(' ')[1]; on the inside.

This could be an error with versions I'm not sure, but I figured I should let you know so that it can be fixed as it's relatively simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant