TODO: Fix timestamps sent by API. Possibly move conversion to roblox server-side

This commit is contained in:
Christopher Cookman 2024-12-08 11:14:49 -07:00
parent a7f79e906e
commit 6ec616515b
2 changed files with 13 additions and 9 deletions

View file

@ -154,7 +154,7 @@ client.on("interactionCreate", async (interaction) => {
}
if (discordId) {
discordUsername = (await client.users.fetch(discordId)).username || "Unknown"
discordUsername = (await client.users.fetch(discordId))?.username || "Unknown"
} else {
discordUsername = null
}

View file

@ -27,10 +27,10 @@ router.get('/v1/bans', async (req, res) => {
const rows = await connection.query('SELECT * FROM bans');
// Convert all timestamps into epoch
rows.forEach(row => {
row.expiresTimestamp = row.expiresTimestamp ? row.expiresTimestamp.getTime() : null
row.banTimestamp = row.banTimestamp ? row.banTimestamp.getTime() : null
row.expiresTimestamp = row.expiresTimestamp ? new Date(row.expiresTimestamp).getTime() : null
row.banTimestamp = row.banTimestamp ? new Date(row.banTimestamp).getTime() : null
row.currentServerTime = new Date().getTime();
});
// Send the results as a JSON response
res.json(rows);
} finally {
@ -56,8 +56,9 @@ router.get("/v1/ban/roblox/:uid", async (req, res) => {
const rows = await connection.query('SELECT * FROM bans WHERE robloxId = ?', [req.params.uid]);
// Convert all timestamps into epoch
rows.forEach(row => {
row.expiresTimestamp = row.expiresTimestamp ? row.expiresTimestamp.getTime() : null
row.banTimestamp = row.banTimestamp ? row.banTimestamp.getTime() : null
row.expiresTimestamp = row.expiresTimestamp ? new Date(row.expiresTimestamp).getTime() : null
row.banTimestamp = row.banTimestamp ? new Date(row.banTimestamp).getTime() : null
row.currentServerTime = new Date().getTime();
});
// Send the results as a JSON response
res.json(rows);
@ -84,9 +85,11 @@ router.get("/v1/ban/discord/:uid", async (req, res) => {
const rows = await connection.query('SELECT * FROM bans WHERE discordId = ?', [req.params.uid]);
// Convert all timestamps into epoch
rows.forEach(row => {
row.expiresTimestamp = row.expiresTimestamp ? row.expiresTimestamp.getTime() : null
row.banTimestamp = row.banTimestamp ? row.banTimestamp.getTime() : null
row.expiresTimestamp = row.expiresTimestamp ? new Date(row.expiresTimestamp).getTime() : null
row.banTimestamp = row.banTimestamp ? new Date(row.banTimestamp).getTime() : null
row.currentServerTime = new Date().getTime();
});
// Send the results as a JSON response
res.json(rows);
} finally {
@ -104,7 +107,8 @@ router.get("/v1/ban/discord/:uid", async (req, res) => {
router.get("/v1/info", (req,res) => {
res.json({
commit_hash: execSync('git rev-parse HEAD').toString().trim(),
reasonFlags
reasonFlags,
currentServerTime: new Date().getTime()
})
})