So I'm making a verification bot for one of my Discord Servers, and I've come across a problem.
Purpose:
When the user first joins, they will be only allowed to talk in one specific channel, the verification channel. When they type $verify {username on-site}
, the bot will reply in-server telling the user to check their DMs to continue. A unique string linked to a verification row in the database will be given, and the discord user will be told to change their status on-site to the given unique ID. Once they do that, they will be given the "Verified" role and will be able to speak on the discord.
The problem: When everything goes right, and the user is ready to be given the role on the discord server, the bot will not give the role. I'm assuming this is because the user that the bot is trying give the role to is not linked to the actual discord server for it, because it's in DMs.
What I'm looking for: If possible, give me an example on how to give a role to a user on a discord server from DMs, or documentation. That would be really helpful!
Code: I'll only include the part that is important, there is no other errors.
snekfetch.get("https://vertineer.com/api/getUniq.php?discord_id="+message.author.id).then(function(r){
console.log("here 2");
let uniq = JSON.parse(r.text);
if(uniq.id == uniq.status){
message.member.addRole("Verified");
message.reply("Success!");
} else {
message.reply("Looks like you didn't change your status to `"+uniq.id+"`, try again with `$finish`.");
}
});
member
and notauthor
. – Ru Chern Chong