From 79345efae4387eea72e056dde9650f3439f82f82 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Sun, 2 Jul 2023 01:44:21 +0500 Subject: [PATCH] rewrite invite router --- Routes/main.js | 20 +++++--------------- theme/dbd-soft-ui/views/guilds.ejs | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Routes/main.js b/Routes/main.js index 4e4c913..d08f7dd 100644 --- a/Routes/main.js +++ b/Routes/main.js @@ -42,23 +42,13 @@ module.exports = (app, config, themeConfig, modules) => { router.get("/invite", (req, res) => { const config = req.config; - config.invite ? null : (config.invite = {}); - const scopes = config.invite.scopes || ["bot"]; + const scopes = config.invite.scopes || ["bot"], + permissions = config.invite.permissions || "0", + other_params = config.invite.otherParams || "", + link = `https://discord.com/oauth2/authorize?client_id=${config.bot.user.id}&scope=${scopes.join("%20")}&permissions=${permissions}&response_type=code${req.query.g ? `&guild_id=${req.query.g}` : ""}${other_params}`; - if (req.query.redirect && !req.query.g) // TODO: Fix req.query.redirect - return res.redirect(`https://discord.com/oauth2/authorize?client_id=${config.invite.clientId || config.bot.user.id}&scope=${scopes.join("%20")}&permissions=${config.invite.permissions || "0"}&response_type=code&redirect_uri=${config.invite.redirectUri}${config.invite.otherParams || ""}`); - if (req.query.redirect && req.query.g) - return res.redirect(`https://discord.com/oauth2/authorize?client_id=${config.invite.clientId || config.bot.user.id}&scope=${scopes.join("%20")}&permissions=${config.invite.permissions || "0"}&response_type=code&redirect_uri=${config.invite.redirectUri}&guild_id=${req.query.g}${config.invite.otherParams || ""}`); - - if (req.query.g) { - let thingymabob = config.invite.redirectUri ? `&response_type=code&redirect_uri=${config.invite.redirectUri}` : null; - if (!thingymabob) thingymabob = config.invite.specialredirectUri ? `&response_type=code&redirect_uri=${config.invite.specialRedirectUri.replace("{SERVER}", req.query.g)}` : ""; - - return res.redirect(`https://discord.com/oauth2/authorize?client_id=${config.invite.clientId || config.bot.user.id}&scope=${scopes.join("%20")}&permissions=${config.invite.permissions || "0"}${thingymabob}&guild_id=${req.query.g}${config.invite.otherParams || ""}`); - } - - res.redirect(`https://discord.com/oauth2/authorize?client_id=${config.invite.clientId || config.bot.user.id}&scope=${scopes.join("%20")}&permissions=${config.invite.permissions || "0"}${config.invite.redirectUri ? `&response_type=code&redirect_uri=${config.invite.redirectUri}` : ""}${config.invite.otherParams || ""}`); + res.redirect(link); }); if (!config.supportServer) config.supportServer = {}; diff --git a/theme/dbd-soft-ui/views/guilds.ejs b/theme/dbd-soft-ui/views/guilds.ejs index 04a3fc3..3009721 100644 --- a/theme/dbd-soft-ui/views/guilds.ejs +++ b/theme/dbd-soft-ui/views/guilds.ejs @@ -55,7 +55,7 @@ else icon = icon + "?size=256" %> - +