Ok, ppl can buy numbers now, good
This commit is contained in:
parent
7f99c0ac29
commit
d15b619b24
24
index.js
24
index.js
|
|
@ -39,6 +39,28 @@ global.db = {
|
||||||
const { REST, Routes } = require("discord.js");
|
const { REST, Routes } = require("discord.js");
|
||||||
const rest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN);
|
const rest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN);
|
||||||
|
|
||||||
|
function checkNitroBoosts() {
|
||||||
|
bvs.getPremiumDIDs().then(dids => {
|
||||||
|
// map to object userid: did
|
||||||
|
const userDIDs = {};
|
||||||
|
dids.forEach(did => {
|
||||||
|
userDIDs[did.userId] = did;
|
||||||
|
});
|
||||||
|
client.guilds.cache.get(process.env.HOME_GUILD).members.fetch().then(members => {
|
||||||
|
members.forEach(member => {
|
||||||
|
if (userDIDs[member.id] && !member.premiumSince) {
|
||||||
|
// I dont feel comfortable handling deletions automatically just yet, log to console
|
||||||
|
console.log(`User ${member.user.tag} (${member.id}) is no longer boosting but still has a DID ${bvs.formatPhoneNumber(userDIDs[member.id].did)}. Please investigate and delete the DID if necessary.`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch(error => {
|
||||||
|
console.error("Error fetching guild members:", error);
|
||||||
|
});
|
||||||
|
}).catch(error => {
|
||||||
|
console.error("Error fetching premium DIDs:", error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
client.on("clientReady", () => {
|
client.on("clientReady", () => {
|
||||||
console.log(`Logged in as ${client.user.tag}!`);
|
console.log(`Logged in as ${client.user.tag}!`);
|
||||||
|
|
@ -58,6 +80,8 @@ client.on("clientReady", () => {
|
||||||
rest.put(Routes.applicationGuildCommands(client.user.id, process.env.HOME_GUILD), { body: commands })
|
rest.put(Routes.applicationGuildCommands(client.user.id, process.env.HOME_GUILD), { body: commands })
|
||||||
.then(() => console.log("Successfully registered application commands."))
|
.then(() => console.log("Successfully registered application commands."))
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
|
checkNitroBoosts();
|
||||||
|
setInterval(checkNitroBoosts, 60 * 60 * 1000)
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('interactionCreate', async interaction => {
|
client.on('interactionCreate', async interaction => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue