Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const fs = require('fs');
- const axios = require('axios');
- module.exports.run = async (bot, message, args) => {
- //Assign variables and read files.
- let settings = JSON.parse(fs.readFileSync('./data/settings.json', 'utf8'));
- let cmdChannel = settings[message.guild.id].defaultcommands
- let linkedroles = JSON.parse(fs.readFileSync('./data/linkedroles.json', 'utf8'));
- let linkedgroups = JSON.parse(fs.readFileSync('./data/linkedgroups.json', 'utf8'));
- let author = message.guild.members.get(message.author.id);
- //Catch if they try and send it in an incorrect channel.
- if (cmdChannel !== "#UnknownChannel#" && message.channel.id !== cmdChannel) {
- message.delete();
- let warningEmbed = new Discord.RichEmbed()
- .setColor('E91E4B')
- .setTitle('Warning:')
- .setDescription(author + " you may only use this command in " + bot.channels.get(cmdChannel).toString() + ".");
- return message.channel.send(warningEmbed)
- .then(botMessage => {botMessage.delete(10000)});
- }
- function updateData(userInfo) {
- if (message.member.roles.some(r => ['Lyn Bypass'].includes(r.name))) return;
- let robloxId;
- if (userInfo && userInfo.robloxId){robloxId = userInfo.robloxId;}
- let robloxUsername;
- if (userInfo && userInfo.robloxUsername){robloxUsername = userInfo.robloxUsername;}
- message.member.setNickname(robloxUsername);
- //Get the group role for the first for loop.
- async function getGroup(i, robloxId){
- console.log('Check 2')
- var response = await axios.get(`https://assetgame.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRole&playerid=${robloxId}&groupid=${i}`);
- return response;
- }
- //Get the group role for the second for loop.
- async function getGroup2(index2, robloxId){
- console.log('Check 3')
- var response = await axios.get(`https://assetgame.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRole&playerid=${robloxId}&groupid=${index2.slice(message.guild.id.length)}`)
- return response;
- }
- //Assign the group roles if the user is in that group.
- for (let i in linkedgroups) {
- getGroup(i, robloxId).then( function(response){
- if (linkedgroups[i].role !== "N/A") {
- let role = message.guild.roles.get(linkedgroups[i].role);
- if (response.data !== "Guest") {
- message.member.addRole(role);
- }
- else message.member.removeRole(role);
- }
- });
- }
- //Assign the group roles for the main group.
- for (let index2 in linkedroles) {
- getGroup2(index2, robloxId).then( function(response){
- var roleName = response.data;
- if (linkedroles[index2].role.includes(roleName)) {
- let role = message.guild.roles.find(r => r.name === roleName);
- message.member.addRole(role);
- for (let roleCheck in linkedroles[index2].role) {
- let roles = linkedroles[index2].role[roleCheck]
- let roleHas = message.member.roles.some(r => r.name === roles);
- if (roleHas === true && roles !== roleName) {
- let removeRole = message.guild.roles.find(r => r.name === roles);
- message.member.removeRole(removeRole);
- }
- }
- }
- })
- }
- }
- ;(async () => {
- var response = await axios({
- url: `https://verify.eryn.io/api/user/${message.author.id}`,
- method: 'get'
- })
- let status;
- if ( response && response.data && response.data.status){status = response.data.status;}
- let robloxUsername;
- if (response && response.data && response.data.robloxUsername){robloxUsername = response.data.robloxUsername;}
- if (status === "ok") {
- let informationEmbed = new Discord.RichEmbed()
- .setColor('3498DB')
- .setTitle('Information:')
- .setDescription(author + " your currently linked Roblox account is `" + robloxUsername + "`. In order to reverify your account, go to https://verify.eryn.io/ and follow the instructions provided.");
- message.channel.send(informationEmbed);
- updateData(response.data);
- }
- else if (status === "error") {
- let informationEmbed = new Discord.RichEmbed()
- .setColor('E91E4B')
- .setTitle('Information:')
- .setDescription(author + " you do not have a linked Roblox account yet, head to https://verify.eryn.io/ and follow the instructions provided to link your account.");
- return message.channel.send(informationEmbed);
- }
- else {
- let errorEmbed = new Discord.RichEmbed()
- .setColor('E91E4B')
- .setTitle('Error:')
- .setDescription(author + " the API, https://verify.eryn.io/, has encountered a critical error. If this persists contact a member of the Manufacturing Department immediately.");
- return message.channel.send(errorEmbed);
- }
- })()
- }
- module.exports.config = {
- command: 'verify'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement