Answer the question
In order to leave comments, you need to log in
How to make an anti-drain Discord system?
Hello. I want to make an anti-drain system for my Discord bot. So that when a certain role is assigned by some user, it is removed. I wrote some code, but anyway, when I give out a role, it is not removed. There is no error in the console.
Here is the code:
#anti sliv system
@client.event
async def on_member_update(before,after):
bad_role = discord.utils.get(client.guild.roles, id =742695680635568139)
member = after.roles
roles = discord.Role
for role in after.roles:
if role.mention == bad_role:
await member.remove_roles(bad_role)
await member.remove_roles(role)
return
Answer the question
In order to leave comments, you need to log in
if role.mention == bad_role:
role.mention
``` Returns a string that allows you to mention the member. ```
I think the problem is in the condition. Instead of iterating, it's better to make a condition
guild_roles_ids = [role.id for role in guild.roles]
if role.id in guild_roles_ids: ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question