Compare commits

..

No commits in common. "78a8c5b834092a7530e46b693e0ab6a685d39ec4" and "f364e545cd508ed51144a016319507a2a768c436" have entirely different histories.

2 changed files with 26 additions and 38 deletions

View File

@ -1,20 +1,9 @@
const { Client, Intents } = require('discord.js');
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS] });
let https;
try {
https = require('node:https');
} catch (err) {
console.error('https support is disabled!');
}
// const D_TOKEN = process.env.DISCORD_TOKEN;
// const O_TOKEN = process.env.AUTH_TOKEN;
const D_TOKEN = process.env.DISCORD_TOKEN;
const O_TOKEN = process.env.AUTH_TOKEN;
// const url = `https://preprod.42ctf.org/api/bot/discord?token=${O_TOKEN}`;
const url = `https://www.42ctf.local/api/bot/discord?token=${token}`;
const https = require('https');
const D_TOKEN = process.env.DISCORD_TOKEN;
const O_TOKEN = process.env.AUTH_TOKEN;
async function get_guildID()
{
@ -26,6 +15,7 @@ async function get_guildID()
async function remove_notlogged(){
let guild = CLIENT.guilds.resolve(await get_guildID());
let token = O_TOKEN;
let url = `https://www.42ctf.local/api/bot/discord?token=${token}`;
await (guild.members.fetch()).then(() => {
console.log("Cache reloaded !");
@ -37,7 +27,15 @@ async function remove_notlogged(){
['top50', guild.roles.cache.get("803729539145924649")]
]);
https.get(url, (res) => {
const options = {
path: '/',
method: 'GET',
rejectUnauthorized: false,
requestCert: true,
agent: false
};
https.get(url, options, (res) => {
let body = "";
res.on("data", (chunk) => {
@ -75,6 +73,7 @@ async function remove_notlogged(){
}
async function rank(token = O_TOKEN){
let url = `https://www.42ctf.local/api/bot/discord?token=${token}`;
let guild = CLIENT.guilds.resolve(await get_guildID());
const rolesCollection = new Map([
@ -83,7 +82,15 @@ async function rank(token = O_TOKEN){
['top50', guild.roles.cache.get("803729539145924649")]
]);
https.get(url, (res) => {
const options = {
path: '/',
method: 'GET',
rejectUnauthorized: false,
requestCert: true,
agent: false
};
https.get(url,options,(res) => {
var body = "";
res.on("data", (chunk) => {
@ -130,25 +137,11 @@ async function rank(token = O_TOKEN){
});
}
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
async function routine() {
while (1) {
rank();
remove_notlogged();
// await sleep(900000)
await sleep(1000 * 120)
}
}
CLIENT.on('ready', () => {
console.log(`Logged in as ${CLIENT.user.tag}!`);
setInterval(rank, 900000);
setInterval(remove_notlogged, 900000);
console.log('started rank() interval !');
routine();
});
CLIENT.login(D_TOKEN);

7
src/package-lock.json generated
View File

@ -1,5 +1,5 @@
{
"name": "src",
"name": "test",
"lockfileVersion": 2,
"requires": true,
"packages": {
@ -15,7 +15,6 @@
"version": "0.13.0",
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.13.0.tgz",
"integrity": "sha512-4L9y26KRNNU8Y7J78SRUN1Uhava9D8jfit/YqEaKi8gQRc7PdqKqk2poybo6RXaiyt/BgKYPfcjxT7WvzGfYCA==",
"deprecated": "no longer supported",
"dependencies": {
"@sapphire/shapeshift": "^2.0.0",
"@sindresorhus/is": "^4.6.0",
@ -37,7 +36,6 @@
"version": "0.7.0-dev.1653480253-68d5169",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.7.0-dev.1653480253-68d5169.tgz",
"integrity": "sha512-s8z+4G82yrIbS0OxqVyitkS72mvE6lxYW8zjsKfpqPAIG6fKQ9n41c9HEsCG1VlWNeQ6F23fKf2hT3bGIdRGsQ==",
"deprecated": "no longer supported",
"engines": {
"node": ">=16.9.0"
}
@ -46,7 +44,6 @@
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-0.4.1.tgz",
"integrity": "sha512-rtWy+AIfNlfjGkAgA2TJLASdqli07aTNQceVGT6RQQiQaEqV0nsfBO4WtDlDzk7PmO3w+InP3dpwEolJI5jz0A==",
"deprecated": "no longer supported",
"dependencies": {
"@discordjs/collection": "^0.7.0-dev",
"@sapphire/async-queue": "^1.3.1",
@ -172,7 +169,6 @@
"version": "13.7.0",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.7.0.tgz",
"integrity": "sha512-iV/An3FEB/CiBGdjWHRtgskM4UuWPq5vjhjKsrQhdVU16dbKrBxA+eIV2HWA07B3tXUGM6eco1wkr42gxxV1BA==",
"deprecated": "Hard crashes on interactions with a channel in the payload, use 13.14.0 and up",
"dependencies": {
"@discordjs/builders": "^0.13.0",
"@discordjs/collection": "^0.6.0",
@ -193,7 +189,6 @@
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.6.0.tgz",
"integrity": "sha512-Ieaetb36l0nmAS5X9Upqk4W7euAO6FdXPxn3I8vBAKEcoIzEZI1mcVcPfCfagGJZSgBKpENnAnKkP4GAn+MV8w==",
"deprecated": "no longer supported",
"engines": {
"node": ">=16.9.0"
}