Role thing

This commit is contained in:
Christopher Cookman 2023-07-30 23:13:11 -06:00
parent 290df777fc
commit 9371b4e189
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 17 additions and 1 deletions

View file

@ -7,5 +7,6 @@
"348601979473362955",
"289884287765839882"
]
}
},
"role": "1135439027957403719"
}

View file

@ -22,6 +22,18 @@ const db = new sqlite3.Database("./database.db");
db.run("CREATE TABLE IF NOT EXISTS points (id TEXT, points INTEGER)");
// update table if it does exist
const updateRoles = () => {
// Get all users in the database
db.all(`SELECT * FROM points`, async (err, rows) => {
// Add the config.discord.role to the user, regardless of points, its just a placeholder
for (let i = 0; i < rows.length; i++) {
let user = await client.users.fetch(rows[i].id);
let member = await client.guilds.cache.get(config.discord.guild).members.fetch(user);
member.roles.add(config.discord.role);
}
});
}
client.on("ready", async () => {
console.log(`${colors.cyan("[INFO]")} Logged in as ${colors.green(client.user.tag)}`)
// Load Commands
@ -42,6 +54,9 @@ client.on("ready", async () => {
}
})();
// Every 5 minutes, update the roles
setInterval(updateRoles, 300000);
updateRoles();
// Log startup time in seconds
console.log(`${colors.cyan("[INFO]")} Startup took ${colors.green((Date.now() - initTime) / 1000)} seconds.`)
});