diff --git a/.fleet/settings.json b/.fleet/settings.json deleted file mode 100644 index a7858d1..0000000 --- a/.fleet/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "editor.guides": [] -} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8103cb8..ecdbd57 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules config.json .idea .run +.fleet diff --git a/assign_roles.js b/assign_roles.js index e39d032..eb0b8c5 100644 --- a/assign_roles.js +++ b/assign_roles.js @@ -4,7 +4,11 @@ const limit = pLimit(10); async function assignRoles(member) { const MANAGED_ROLES = ["Supervisor", "Administrator", "New Member", "PPL", "IR", "CMEL", "ATPL", "Flight Instructor", "Flight Examiner", "No Military Rating", "M1", "M2","M3","M4"]; - const discordCidResponse = await fetch(`https://api.vatsim.net/v2/members/discord/${member.user.id}`).catch(error => console.trace(error)); + const discordCidResponse = await fetch(`https://api.vatsim.net/v2/members/discord/${member.user.id}`, { + headers : { + "User-Agent" : 'PTDDiscordBot' + } + }).catch(error => console.trace(error)); if (!discordCidResponse || discordCidResponse.status !== 200) { console.log(`The discordCidResponse could not be completed as dialed for ${member.displayName}`) return @@ -17,7 +21,10 @@ async function assignRoles(member) { if (discordCidBody.detail === 'Not Found') { return; } - const ratingsResponse = await fetch(`https://api.vatsim.net/v2/members/${cid}`).catch(error => console.trace(error)); + const ratingsResponse = await fetch(`https://api.vatsim.net/v2/members/${cid}`, { + headers : { + "User-Agent" : 'PTDDiscordBot' + }}).catch(error => console.trace(error)); if (ratingsResponse.status !== 200) { console.log(`The ratingsResponse could not be completed as dialed due to a status of ${ratingsResponse.status}`) } diff --git a/events/ready.js b/events/ready.js index 119dba3..f1e2be4 100644 --- a/events/ready.js +++ b/events/ready.js @@ -9,8 +9,12 @@ module.exports = { setInterval(async function() { const guild = client.guilds.cache.get("901078003482783765"); const members = await guild.members.fetch(); - members.forEach(member => assignRoles(member)) + members.forEach(member => + setInterval(function (){ + assignRoles(member) + },500) + ) console.log("I have assigned everyone's roles"); - },60*60*1000) + },2*12*60*60*1000) }, };