rage quit
This commit is contained in:
parent
4340d0814d
commit
283fbf76ec
52
bot.js
52
bot.js
|
@ -1,4 +1,4 @@
|
||||||
const { Client, Intents, Util } = require('discord.js');
|
const { Client, Intents } = require('discord.js');
|
||||||
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
|
|
||||||
|
@ -12,47 +12,54 @@ async function get_guildID()
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rank(token = O_TOKEN){
|
async function rank(token = O_TOKEN){
|
||||||
var url = `https://preprod.42ctf.org/api/bot/discord?token=${token}`;
|
let url = `https://preprod.42ctf.org/api/bot/discord?token=${token}`;
|
||||||
|
let guild = CLIENT.guilds.resolve(await get_guildID());
|
||||||
|
|
||||||
|
const rolesCollection = new Map([
|
||||||
|
['top1', guild.roles.cache.get("943545814758854686")],
|
||||||
|
['top10', guild.roles.cache.get("943545892030517278")],
|
||||||
|
['top50', guild.roles.cache.get("943545946309029958")]
|
||||||
|
]);
|
||||||
|
|
||||||
https.get(url,(res) => {
|
https.get(url,(res) => {
|
||||||
let body = "";
|
var body = "";
|
||||||
|
|
||||||
res.on("data", (chunk) => {
|
res.on("data", (chunk) => {
|
||||||
body += chunk;
|
body += chunk;
|
||||||
});
|
});
|
||||||
res.on("end", () => {
|
res.on("end", () => {
|
||||||
try {
|
try {
|
||||||
let json = JSON.parse(body);
|
var json = JSON.parse(body);
|
||||||
let v = new Map(Object.entries(json))
|
let v = new Map(Object.entries(json))
|
||||||
v.forEach(async (key, value) => {
|
v.forEach(async (key, value) => {
|
||||||
let guild = CLIENT.guilds.resolve(await get_guildID());
|
|
||||||
let user = guild.members.fetch(value);
|
let user = guild.members.fetch(value);
|
||||||
let rank = parseInt(key);
|
let rank = parseInt(key);
|
||||||
const roles = new Map([
|
|
||||||
['top1', guild.roles.cache.get("798638767359524875")],
|
|
||||||
['top10', guild.roles.cache.get("801787467064672286")],
|
|
||||||
['top50', guild.roles.cache.get("803729539145924649")]
|
|
||||||
]);
|
|
||||||
if(rank == 1)
|
if(rank == 1)
|
||||||
{
|
{
|
||||||
await (await user).roles.add(roles.get('top1'));
|
await (await user).roles.add(rolesCollection.get('top1'));
|
||||||
await (await user).roles.remove(roles.get('top10'));
|
await (await user).roles.remove(rolesCollection.get('top10'));
|
||||||
await (await user).roles.remove(roles.get('top50'));
|
await (await user).roles.remove(rolesCollection.get('top50'));
|
||||||
}
|
}
|
||||||
else if(rank <= 10)
|
else if(rank <= 10)
|
||||||
{
|
{
|
||||||
await (await user).roles.remove(roles.get('top1'));
|
await (await user).roles.remove(rolesCollection.get('top1'));
|
||||||
await (await user).roles.add(roles.get('top10'));
|
await (await user).roles.add(rolesCollection.get('top10'));
|
||||||
await (await user).roles.remove(roles.get('top50'));
|
await (await user).roles.remove(rolesCollection.get('top50'));
|
||||||
}
|
}
|
||||||
else if(rank <= 50)
|
else if(rank <= 50)
|
||||||
{
|
{
|
||||||
await (await user).roles.remove(roles.get('top1'));
|
await (await user).roles.remove(rolesCollection.get('top1'));
|
||||||
await (await user).roles.remove(roles.get('top10'));
|
await (await user).roles.remove(rolesCollection.get('top10'));
|
||||||
await (await user).roles.add(roles.get('top50'));
|
await (await user).roles.add(rolesCollection.get('top50'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await (await user).roles.remove(rolesCollection.get('top1'));
|
||||||
|
await (await user).roles.remove(rolesCollection.get('top10'));
|
||||||
|
await (await user).roles.remove(rolesCollection.get('top50'));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log("done");
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
};
|
};
|
||||||
|
@ -64,7 +71,8 @@ function rank(token = O_TOKEN){
|
||||||
|
|
||||||
CLIENT.on('ready', () => {
|
CLIENT.on('ready', () => {
|
||||||
console.log(`Logged in as ${CLIENT.user.tag}!`);
|
console.log(`Logged in as ${CLIENT.user.tag}!`);
|
||||||
setInterval(rank, 900000);
|
setInterval(rank, 5000);
|
||||||
|
setInterval(remove_notlogged, 5000);
|
||||||
console.log('started rank() interval !');
|
console.log('started rank() interval !');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue