From c8004bed7f268121579e13d8eeef39db7b2170d6 Mon Sep 17 00:00:00 2001 From: Starthur Date: Sat, 28 May 2022 12:44:28 +0200 Subject: [PATCH 1/2] Change instruction for use docker-compose --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 918d601..1c1a3ad 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,6 @@ This bot allows you to automatically assign the top1/top10/top50 roles on the 42CTF Discord server. -To use it you just have to create the docker container : -``` -docker build -t discord_bot . -``` Create an `env.list` file containing : ``` @@ -15,5 +11,5 @@ AUTH_TOKEN= And then run it with : ``` -docker run -d --env-file env.list --name discord_bot +docker-compose up -d ``` From 64f188b6b19a31375da8e07deafdd7340399eea8 Mon Sep 17 00:00:00 2001 From: Starthur Date: Sat, 28 May 2022 13:35:09 +0200 Subject: [PATCH 2/2] Change org to local --- README.md | 2 +- src/bot.js | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1c1a3ad..c745673 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This bot allows you to automatically assign the top1/top10/top50 roles on the 42CTF Discord server. -Create an `env.list` file containing : +Create an `env_file` file containing : ``` DISCORD_TOKEN= AUTH_TOKEN= diff --git a/src/bot.js b/src/bot.js index 473f9e1..2e14456 100644 --- a/src/bot.js +++ b/src/bot.js @@ -15,7 +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.org/api/bot/discord?token=${token}`; + let url = `https://www.42ctf.local/api/bot/discord?token=${token}`; await (guild.members.fetch()).then(() => { console.log("Cache reloaded !"); @@ -27,9 +27,17 @@ 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) => { body += chunk; }); @@ -54,7 +62,7 @@ async function remove_notlogged(){ await user.roles.remove(rolesCollection.get('top50')); } }) - } + } catch (error) { console.error(error.message); }; @@ -65,7 +73,7 @@ async function remove_notlogged(){ } async function rank(token = O_TOKEN){ - let url = `https://www.42ctf.org/api/bot/discord?token=${token}`; + let url = `https://www.42ctf.local/api/bot/discord?token=${token}`; let guild = CLIENT.guilds.resolve(await get_guildID()); const rolesCollection = new Map([ @@ -74,9 +82,17 @@ 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) => { body += chunk; });