-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.js
42 lines (36 loc) · 1.18 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const express = require('express')
const { serverId } = require('./environment')
const { useGets } = require('./gets')
const { client } = require('./client')
const {useLog} = require("./console")
const router = express.Router()
const guild = client.guilds.cache.get(serverId);
if (!guild) {
useLog.error("server not found.")
return
}
router.get('/', async (req, res) => {
res.redirect('https://thundis.hideko.cf');
});
router.get('/id/:userId', async (req, res) => {
const userTag = req.params.userId;
if (!guild) {
console.error('Guild is not defined.');
res.status(500).send('Internal Server Error');
return;
}
const user = await guild.members.fetch(userTag);
await useGets(res, req, guild, user);
});
router.get('/tag/:userTag', async (req, res) => {
const userTag = req.params.userTag;
if (!guild) {
console.error('Guild is not defined.');
res.status(500).send('Internal Server Error');
return;
}
const userinfo = client.users.cache.find((user) => user.tag === userTag);
const user = await guild.members.fetch(userinfo.id);
await useGets(res, req, guild, user);
});
module.exports = router;