I have spotted some posts regarding the same topic, but not the exact problem. I have also referred to javascript discords, where they were unable to assist me with my problem.
So to inform you, The purpose of this verification system is to make sure the user understood the rules and can proceed to have the rest of the discord unlocked after he adds a checkmark reaction.
I have made a bot that has the mand |message and it works fine and all, but I then want the bot to react to its own message once sent, and then wait for a user to also add a reaction, which will trigger a function, in this case. Triggering the bot to send a PM to the user and giving him a rank.
The bot adds his reaction fine, and upon reacting from me as an example it sends me a PM, but in the PM between me and the bot, the bot reacts once again to his message. And this might be because of the code checking if the message author is the bot.
I was told in the JS Discord that the messageReactionAdd function has a Message Property, however upon searching I couldn't find a way to implement this into my code. How would I do so? Also trying to give the user a rank also spits out an error, and I am simply stuck between understanding and making stuff work. I am getting confused with my own code, and I have minimal understanding of what I am doing, so with that said, Can anyone assist me doing this change, so I can get it in my head? Giving me links to the discord.js documentation is just making me more confused, and the only way for me to learn is by creating, and successfully making it work. Any help is appreciated of course.
So, here is the code for the messageReactionAdd:
bot.on('messageReactionAdd', (reaction, user) => {
if(reaction.emoji.name === "✅") {
if(user === bot.user) return;
// if(bot.channel === "dm") return;
// let role = bot.guild.roles.find("name", "C - Verified");
// let role1 = bot.guild.roles.find("name", "C - Unverified");
//if(user.roles.has(role.id));
//await(user.addRole(role.id) && user.removeRole(role1.id));
user.send("Thank you for being apart of the munity! As a thanks for accepting the rules, you have been awarded the verified role!");
return;
}
});
And here is the code for the react function itself:
513769507907567628 is the bots' ID.
bot.on("message", async message => {
if(message.author.id != "513769507907567628") return;
message.react("✅");
});
So, if you have any input that'd be great! If you can join a Discord Call please message me, That'd be the easiest and quickest.
Regards, Marius.
I have spotted some posts regarding the same topic, but not the exact problem. I have also referred to javascript discords, where they were unable to assist me with my problem.
So to inform you, The purpose of this verification system is to make sure the user understood the rules and can proceed to have the rest of the discord unlocked after he adds a checkmark reaction.
I have made a bot that has the mand |message and it works fine and all, but I then want the bot to react to its own message once sent, and then wait for a user to also add a reaction, which will trigger a function, in this case. Triggering the bot to send a PM to the user and giving him a rank.
The bot adds his reaction fine, and upon reacting from me as an example it sends me a PM, but in the PM between me and the bot, the bot reacts once again to his message. And this might be because of the code checking if the message author is the bot.
I was told in the JS Discord that the messageReactionAdd function has a Message Property, however upon searching I couldn't find a way to implement this into my code. How would I do so? Also trying to give the user a rank also spits out an error, and I am simply stuck between understanding and making stuff work. I am getting confused with my own code, and I have minimal understanding of what I am doing, so with that said, Can anyone assist me doing this change, so I can get it in my head? Giving me links to the discord.js documentation is just making me more confused, and the only way for me to learn is by creating, and successfully making it work. Any help is appreciated of course.
So, here is the code for the messageReactionAdd:
bot.on('messageReactionAdd', (reaction, user) => {
if(reaction.emoji.name === "✅") {
if(user === bot.user) return;
// if(bot.channel === "dm") return;
// let role = bot.guild.roles.find("name", "C - Verified");
// let role1 = bot.guild.roles.find("name", "C - Unverified");
//if(user.roles.has(role.id));
//await(user.addRole(role.id) && user.removeRole(role1.id));
user.send("Thank you for being apart of the munity! As a thanks for accepting the rules, you have been awarded the verified role!");
return;
}
});
And here is the code for the react function itself:
513769507907567628 is the bots' ID.
bot.on("message", async message => {
if(message.author.id != "513769507907567628") return;
message.react("✅");
});
So, if you have any input that'd be great! If you can join a Discord Call please message me, That'd be the easiest and quickest.
Share Improve this question edited Nov 25, 2018 at 20:20 Ryan Schaefer 3,1201 gold badge28 silver badges48 bronze badges asked Nov 25, 2018 at 20:15 MariusMarius 731 silver badge11 bronze badges 0Regards, Marius.
1 Answer
Reset to default 3If your problem occured here:
await(user.addRole(role.id) && user.removeRole(role1.id));
then it is because:
1) await
only exists inside async
functions.
2) you cannot just chain promises with &&
, a && b
will result in b
and that gets then awaited, so in your case you only wait for the removal.
bot.on('messageReactionAdd', async (reaction, user) => {
if(reaction.emoji.name === "✅") return;
if(user === bot.user) return;
let role = bot.guild.roles.find("name", "C - Verified");
let role1 = bot.guild.roles.find("name", "C - Unverified");
await user.addRole(role.id);
await user.removeRole(role1.id);
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745412889a4626611.html
评论列表(0条)