So i\'ve been trying to get the bot to announce whenever a member gets a role granted, i know that this code may not make sense at all, but that\'s why i\'m asking: How coul
First you have to check that the user got a new role. Then you can check that the role they got is one of the ones you're looking for:
@bot.event
async def on_member_update(before, after):
if len(before.roles) < len(after.roles):
new_role = next(role for role in after.roles if role not in before.roles)
if new_role.name in ('android', 'human'):
fmt = "{0.mention} your role request has been accepted! :confetti_ball: You've been granted the role '{1}'"
await bot.send_message(bot.get_channel('495285593711050754'), fmt.format(after, new_role.name))
elif new_role.name in ('moderator'):
fmt = "{0.mention} you are now part of the CyberLife staff, we're so excited to have you here! :confetti_ball:"
await bot.send_message(bot.get_channel('495285593711050754'), fmt.format(after))