Compare commits

..

No commits in common. "f364e545cd508ed51144a016319507a2a768c436" and "9b1c89854e37b96ce8d64ef1d07d990209a941a2" have entirely different histories.

2 changed files with 13 additions and 25 deletions

View File

@ -2,8 +2,12 @@
This bot allows you to automatically assign the top1/top10/top50 roles on the 42CTF Discord server. 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_file` file containing : Create an `env.list` file containing :
``` ```
DISCORD_TOKEN=<token_discord> DISCORD_TOKEN=<token_discord>
AUTH_TOKEN=<api_42CTF_token> AUTH_TOKEN=<api_42CTF_token>
@ -11,5 +15,5 @@ AUTH_TOKEN=<api_42CTF_token>
And then run it with : And then run it with :
``` ```
docker-compose up -d docker run -d --env-file env.list --name discord_bot
``` ```

View File

@ -15,7 +15,7 @@ async function get_guildID()
async function remove_notlogged(){ async function remove_notlogged(){
let guild = CLIENT.guilds.resolve(await get_guildID()); let guild = CLIENT.guilds.resolve(await get_guildID());
let token = O_TOKEN; let token = O_TOKEN;
let url = `https://www.42ctf.local/api/bot/discord?token=${token}`; let url = `https://www.42ctf.org/api/bot/discord?token=${token}`;
await (guild.members.fetch()).then(() => { await (guild.members.fetch()).then(() => {
console.log("Cache reloaded !"); console.log("Cache reloaded !");
@ -27,17 +27,9 @@ async function remove_notlogged(){
['top50', guild.roles.cache.get("803729539145924649")] ['top50', guild.roles.cache.get("803729539145924649")]
]); ]);
const options = { https.get(url,(res) => {
path: '/',
method: 'GET',
rejectUnauthorized: false,
requestCert: true,
agent: false
};
https.get(url, options, (res) => {
let body = ""; let body = "";
res.on("data", (chunk) => { res.on("data", (chunk) => {
body += chunk; body += chunk;
}); });
@ -62,7 +54,7 @@ async function remove_notlogged(){
await user.roles.remove(rolesCollection.get('top50')); await user.roles.remove(rolesCollection.get('top50'));
} }
}) })
} }
catch (error) { catch (error) {
console.error(error.message); console.error(error.message);
}; };
@ -73,7 +65,7 @@ async function remove_notlogged(){
} }
async function rank(token = O_TOKEN){ async function rank(token = O_TOKEN){
let url = `https://www.42ctf.local/api/bot/discord?token=${token}`; let url = `https://www.42ctf.org/api/bot/discord?token=${token}`;
let guild = CLIENT.guilds.resolve(await get_guildID()); let guild = CLIENT.guilds.resolve(await get_guildID());
const rolesCollection = new Map([ const rolesCollection = new Map([
@ -82,17 +74,9 @@ async function rank(token = O_TOKEN){
['top50', guild.roles.cache.get("803729539145924649")] ['top50', guild.roles.cache.get("803729539145924649")]
]); ]);
const options = { https.get(url,(res) => {
path: '/',
method: 'GET',
rejectUnauthorized: false,
requestCert: true,
agent: false
};
https.get(url,options,(res) => {
var body = ""; var body = "";
res.on("data", (chunk) => { res.on("data", (chunk) => {
body += chunk; body += chunk;
}); });