Hey hey! I’ve successfully made a discord bot that can do Roblox verification, however, I have one error. The bot does not award one or the other of the two roles it is set up to award when I use the rerole, update, getroles or verify commands. I feel this very strange as it switches between the two roles that it does not award. I’ll send my code for the rerole command (This is the most problematic one). This bot does not use any databases for verified users.
const Discord = require("discord.js")
const rbx = require("noblox.js")
const {
Client,
Collection,
MessageEmbed
} = require("discord.js");
module.exports = {
name: 'update',
aliases: ['rerole'],
description: 'Update a users roles!',
usage: '<>',
cooldown: 2,
ownerOnly: false,
guildOnly: true,
async run(client, message, args) {
var user = message.mentions.members.first();
var nick = user.nickname
if (nick === null){
var coolVar = user.user.tag
var hot = coolVar.split('#');
nick = hot[0]
}
//message.reply(`${nick}`)
if (!message.member.roles.cache.get('782791336792293387')) {
return message.channel.send(
new MessageEmbed()
.setColor("YELLOW")
.setTitle("Error")
.setDescription("You lack permission to do that!")
.setTimestamp()
.setAuthor(
"Barbados Helper",
"https://t3.rbxcdn.com/11460431a6b57f9392798ed6bf8b8db1"
)
)
} else {
if(user){
rbx.getIdFromUsername(nick).then(foundId => {
const foundUsername = new Discord.MessageEmbed()
.setColor("YELLOW")
.setTitle("Barbados Verification")
.setDescription(`Barbados has successfully updated ${user} roles!`)
.setFooter("Barbados")
.setTimestamp()
.setAuthor(
"Barbados Helper",
"https://t3.rbxcdn.com/11460431a6b57f9392798ed6bf8b8db1"
)
rbx.getRankNameInGroup(8473187, foundId).then(role => {
user.roles.remove(user.roles.cache)
message.channel.send(foundUsername)
var role = message.guild.roles.cache.find(r => r.name == `${role}`)
if (role === "Guest") {
user.roles.add(message.guild.roles.cache.find(r => r.name == `Verified`))
user.roles.add(message.guild.roles.cache.get("782783909066047498"))
user.roles.add(message.guild.roles.cache.find(r => r.name == `TalkPerms`))
} else {
user.roles.add(message.guild.roles.cache.find(r => r.name == `Verified`))
user.roles.add(role)
user.roles.add(message.guild.roles.cache.find(r => r.name == `TalkPerms`))
}
})
})
}}
}
}