I've been improving and improving my bot. Now, I've figured out how to make the bot purge messages, but a purge message, shouldn't be allowed to any member, only to people with certain role.
I've done this code:
if author.roles.has("BotModerator"):
I've looked for it, on this website(https://anidiotsguide.gitbooks.io/discord-js-bot-guide/information/understanding_roles.html), but seems that they're coding with Java, how can I do it in Python?
By the way, the error shown in the output is 'list' object has no atribute 'has'
The roles a User has is a list of role objects, you'll need to access the name property of the role. You can use list comprehension.
if "botmoderator" in [y.name.lower() for y in author.roles]:
But of course, this limits that command to only people with the specific role, BotModerators. It can't be used in another server unless they aswell have a role called BotModerator. I recommend you using the id instead. If you don't know how, tag the role then put a backslash in front of the name then send. Should show you the role's id. Then you can use that instead.
if "role_id" in [y.id for y in author.roles]:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With