'discord bot on_guild_role_update, problem with permissions
I tryed to make logs with admin`s activity how to specify the permission instead of these incomprehensible numbers
@bot.event
async def on_guild_role_update(before, after):
embed = discord.Embed(
color=0xf04848
)
embed.set_author(name=f'📝 Role `{before.name}` was changed!')
if before.color != after.color:
embed.add_field(name='Color:', value=f'{before.color} --> {after.color}', inline=False)
if before.name != after.name:
embed.add_field(name='Name:', value=f'{before.name} --> {after.name}', inline=False)
if before.permissions != after.permissions:
embed.add_field(name='Permissions:', value=f'{before.permissions} --> {after.permissions}', inline=False)
await bot.get_channel(911633362949648464).send(embed=embed)
Solution 1:[1]
you can write something like
if before.permissions != after.permissions:
text = ""
If before.permissions.change_nickname != after.permissions.change_nickname:
text = f"{text}\n{'+change nickname' if after.permissions.change_nickname != True else '-change nickname'} --> {'+change nickname' if after.permissions.change_nickname == True else '-change nickname'}"
#and so with all the rights and then just
embed.add_field(name="Permissions:", value=text, inline=False)
conclusion(if there was no right and it was given)
Permissins:
-change nickname --> +change nickname
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |