botJS #1

Merged
Starthur merged 12 commits from botJS into main 2022-05-27 09:49:52 +02:00
4 changed files with 29 additions and 29 deletions
Showing only changes of commit 4340d0814d - Show all commits

5
.gitignore vendored
View File

@ -1,2 +1,5 @@
.vscode
.vscode
node_modules
node_modules/npm/node_modules/pacote/lib/util

37
bot.js
View File

@ -1,13 +1,18 @@
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { Client, Intents} = require('discord.js');
const { Client, Intents, Util } = require('discord.js');
const CLIENT = new Client({ intents: [Intents.FLAGS.GUILDS] });
const https = require('https');
const GUILD = '42ctf';
const TOKEN = "OTQzNTA2NTgxMjkzNzc2OTQ3.Yg0C-g.XOjFinUc-Gt1gwtrSILPb0Mlspo";
const D_TOKEN = process.env.DISCORD_TOKEN;
const O_TOKEN = process.env.AUTH_TOKEN;
function rank(token = "test"){
async function get_guildID()
{
let Guilds = CLIENT.guilds;
let v = (await Guilds.fetch()).keyAt(0);
return v;
}
function rank(token = O_TOKEN){
var url = `https://preprod.42ctf.org/api/bot/discord?token=${token}`;
https.get(url,(res) => {
let body = "";
@ -20,16 +25,14 @@ function rank(token = "test"){
let json = JSON.parse(body);
let v = new Map(Object.entries(json))
v.forEach(async (key, value) => {
console.log(key, value)
let guild = CLIENT.guilds.fetch('943459216901955604');
let user = (await guild).members.fetch(value);
let guild = CLIENT.guilds.resolve(await get_guildID());
let user = guild.members.fetch(value);
let rank = parseInt(key);
const roles = new Map([
['top1', (await guild).roles.cache.get("943545814758854686")],
['top10', (await guild).roles.cache.get("943545892030517278")],
['top50', (await guild).roles.cache.get("943545946309029958")]
['top1', guild.roles.cache.get("798638767359524875")],
['top10', guild.roles.cache.get("801787467064672286")],
['top50', guild.roles.cache.get("803729539145924649")]
]);
console.log((await user).user.tag);
if(rank == 1)
{
await (await user).roles.add(roles.get('top1'));
@ -65,10 +68,4 @@ CLIENT.on('ready', () => {
console.log('started rank() interval !');
});
CLIENT.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
});
CLIENT.login(TOKEN);
CLIENT.login(D_TOKEN);

14
package-lock.json generated
View File

@ -6,7 +6,7 @@
"": {
"dependencies": {
"@discordjs/rest": "^0.3.0",
"discord-api-types": "^0.27.1",
"discord-api-types": "^0.27.2",
"discord.js": "^13.6.0",
"npm": "^8.5.0"
}
@ -160,9 +160,9 @@
}
},
"node_modules/discord-api-types": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.27.1.tgz",
"integrity": "sha512-NhOrRs3TDx/p/e7+VCzcvtVz/Wkqa/olS82HJb2aM/oI0CLcnB+lJMXWa8wjn57XviFBcMMR0poqUMXx0IqTkQ=="
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.27.2.tgz",
"integrity": "sha512-70Uy283dXKpphwuVQIhQJCBAMIxLwCywdyjTKAjjrzFONZZIRQr9oupj3K1rS+hGnI6cp6y7eStRQvTbeSC+Zw=="
},
"node_modules/discord.js": {
"version": "13.6.0",
@ -2756,9 +2756,9 @@
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"discord-api-types": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.27.1.tgz",
"integrity": "sha512-NhOrRs3TDx/p/e7+VCzcvtVz/Wkqa/olS82HJb2aM/oI0CLcnB+lJMXWa8wjn57XviFBcMMR0poqUMXx0IqTkQ=="
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.27.2.tgz",
"integrity": "sha512-70Uy283dXKpphwuVQIhQJCBAMIxLwCywdyjTKAjjrzFONZZIRQr9oupj3K1rS+hGnI6cp6y7eStRQvTbeSC+Zw=="
},
"discord.js": {
"version": "13.6.0",

View File

@ -1,7 +1,7 @@
{
"dependencies": {
"@discordjs/rest": "^0.3.0",
"discord-api-types": "^0.27.1",
"discord-api-types": "^0.27.2",
"discord.js": "^13.6.0",
"npm": "^8.5.0"
}