mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-09 21:51:29 +08:00
unlink discord sends a command to the bot to take away the roles
This commit is contained in:
parent
1ce7533aa5
commit
c9fcb10958
1 changed files with 14 additions and 1 deletions
|
|
@ -205,8 +205,21 @@ class UserController {
|
|||
static async unlinkDiscord(req, res, next) {
|
||||
try {
|
||||
const { uid } = req.decodedToken;
|
||||
let userInfo;
|
||||
try {
|
||||
userInfo = await UsersDAO.getUser(uid);
|
||||
} catch (e) {
|
||||
throw new MonkeyError(400, "User not found.");
|
||||
}
|
||||
if (!userInfo.discordId) {
|
||||
throw new MonkeyError(
|
||||
400,
|
||||
"User does not have a linked Discord account"
|
||||
);
|
||||
}
|
||||
await BotDAO.unlinkDiscord(uid, userInfo.discordId);
|
||||
await UsersDAO.unlinkDiscord(uid);
|
||||
Logger.log("user_discord_unlinked", "", uid);
|
||||
Logger.log("user_discord_unlinked", userInfo.discordId, uid);
|
||||
return res.status(200).send();
|
||||
} catch (e) {
|
||||
return next(e);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue