Add /discord endpoint; Add discord invite to README;
This commit is contained in:
parent
43e539f534
commit
e854c1ec5d
|
@ -2,6 +2,8 @@
|
|||
The UBS Project is brought to you by the RTECH Development Team.
|
||||
This project aims to solve a simple but crucial problem: managing bans across roblox and discord. And making it easy to impliment, to keep communities safe.
|
||||
|
||||
## [Join the RTECH Discord!](https://ubs.rtech.foundation/discord)
|
||||
|
||||
## Server Status
|
||||

|
||||

|
||||
|
|
14
index.js
14
index.js
|
@ -74,6 +74,20 @@ app.get("/", (req, res) => {
|
|||
});
|
||||
});
|
||||
|
||||
var cached_invite = { code: "", expires: 0 }
|
||||
|
||||
app.get('/discord', async (req, res) => {
|
||||
if (cached_invite.expires > Date.now()) {
|
||||
return res.redirect(`https://discord.gg/${cached_invite.code}`)
|
||||
} else {
|
||||
const data = await fetch(`https://discord.com/api/guilds/${process.env.ADMIN_GUILD}/widget.json`)
|
||||
const json = await data.json()
|
||||
cached_invite.code = json.instant_invite
|
||||
cached_invite.expires = Date.now() + 60000
|
||||
return res.redirect(json.instant_invite)
|
||||
}
|
||||
});
|
||||
|
||||
// Flags
|
||||
const reasonFlagTypes = [
|
||||
"OTHER",
|
||||
|
|
Loading…
Reference in a new issue