rewrite invite router

This commit is contained in:
Jonny_Bro (Nikita) 2023-07-02 01:44:21 +05:00
parent 889f9fc954
commit 79345efae4
2 changed files with 6 additions and 16 deletions

View file

@ -42,23 +42,13 @@ module.exports = (app, config, themeConfig, modules) => {
router.get("/invite", (req, res) => { router.get("/invite", (req, res) => {
const config = req.config; 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 res.redirect(link);
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 || ""}`);
}); });
if (!config.supportServer) config.supportServer = {}; if (!config.supportServer) config.supportServer = {};

View file

@ -55,7 +55,7 @@
else icon = icon + "?size=256" else icon = icon + "?size=256"
%> %>
<!--href="../invite?g=<%- req.session.guilds[i].id %>"--> <!--href="../invite?g=<%- req.session.guilds[i].id %>"-->
<a onclick="const newWindow = window.open(`/invite?g=<%- req.session.guilds[i].id %><%- config.invite?.redirectUri ? `&redirect=${config.invite.redirectUri.replace('{SERVER}', req.session.guilds[i].id)}` : '' %>`, 'Add bot to guild', 'scrollbars=no, resizable=no, status=no, location=no, toolbar=no, menubar=no, width=500, height=800'); checkRefresh()"> <a onclick="const newWindow = window.open(`/invite?g=<%- req.session.guilds[i].id %>`, 'Add bot to guild', 'scrollbars=no, resizable=no, status=no, location=no, toolbar=no, menubar=no, width=500, height=800'); checkRefresh()">
<div max="20" scale="110" perspective="700" class="_82d1" <div max="20" scale="110" perspective="700" class="_82d1"
data-guildname="<%- req.session.guilds[i].name %>" data-guildname="<%- req.session.guilds[i].name %>"
style="background-image: url(&quot;<%- icon %>&quot;); filter: grayscale(1);"></div> style="background-image: url(&quot;<%- icon %>&quot;); filter: grayscale(1);"></div>