fixed error

This commit is contained in:
Jack 2021-08-24 02:09:04 +01:00
parent 05626fda06
commit df7e03b0df

View file

@ -115,6 +115,17 @@ class UserController {
static async linkDiscord(req, res, next) {
try {
const { uid } = req.decodedToken;
let requser;
try {
requser = await UsersDAO.getUser(uid);
} catch (e) {
requser = null;
}
if (user?.banned === true) {
throw new MonkeyError(403, "Banned accounts cannot link with Discord");
}
let discordFetch = await fetch("https://discord.com/api/users/@me", {
headers: {
authorization: `${req.body.data.tokenType} ${req.body.data.accessToken}`,
@ -141,9 +152,6 @@ class UserController {
"This Discord account is already linked to a different account"
);
}
if (user.banned === true) {
throw new MonkeyError(403, "Banned accounts cannot link with Discord");
}
await UsersDAO.linkDiscord(uid, did);
await BotDAO.linkDiscord(uid, did);
return res.status(200).json({