Working on waitingListUpdate (WIP)
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
||||||
const mongoose = require('mongoose');
|
const mongoose = require('mongoose');
|
||||||
const waitinglist = require('../../schemas/waitinglistSchema.js');
|
const waitinglist = require('../../schemas/waitinglistSchema.js');
|
||||||
|
const env = require('dotenv').config();
|
||||||
|
const key = process.env.HYPIXELAPIKEY;
|
||||||
|
const { hypixelGuildID } = require("../../config/options.json")
|
||||||
|
const fetch = require("axios");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'waitinglistupdate',
|
name: 'waitinglistupdate',
|
||||||
@@ -14,15 +18,31 @@ module.exports = {
|
|||||||
const message = interaction.message;
|
const message = interaction.message;
|
||||||
const embed = message.embeds[0];
|
const embed = message.embeds[0];
|
||||||
const accepted = await waitinglist.find()
|
const accepted = await waitinglist.find()
|
||||||
|
const guildAPI = "https://api.hypixel.net/guild"
|
||||||
|
const guild = guildAPI + "?key=" + key + "&player="
|
||||||
|
|
||||||
console.log(accepted);
|
for (let i = 0; i < accepted.length; i++) {
|
||||||
|
|
||||||
|
const uuid = accepted[i].uuid
|
||||||
|
const check = await fetch(guild + uuid)
|
||||||
|
|
||||||
|
if (check.data.guild._id === hypixelGuildID) {
|
||||||
|
await waitinglist.findOneAndDelete({ uuid: uuid })
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
let fields = [];
|
let fields = [];
|
||||||
|
|
||||||
for (let i = 0; i < accepted.length; i++) {
|
for (let i = 0; i < accepted.length; i++) {
|
||||||
|
|
||||||
|
const timestamp1 = accepted[i].timestamp / 1000
|
||||||
|
const timestamp = Math.floor(timestamp1)
|
||||||
|
|
||||||
fields.push({
|
fields.push({
|
||||||
name: `${i + 1}. ${accepted[i].name}`,
|
name: `${i + 1}. ${accepted[i].IGN}`,
|
||||||
value: `TS: <t:${accepted[i].timestamp}> | UUID: ${accepted[i].uuid}`
|
value: `TS: <t:${timestamp}:R>`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,13 +53,10 @@ module.exports = {
|
|||||||
color: embed.color,
|
color: embed.color,
|
||||||
footer: embed.footer,
|
footer: embed.footer,
|
||||||
thumbnail: embed.thumbnail,
|
thumbnail: embed.thumbnail,
|
||||||
fierlds: fields,
|
fields: fields,
|
||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Updated the waiting list.');
|
|
||||||
|
|
||||||
await interaction.editReply({ content: 'Updating the waiting list...', ephemeral: true });
|
await interaction.editReply({ content: 'Updating the waiting list...', ephemeral: true });
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user