Enhance role validation in ItemManager by adding support for role mentions. Update hierarchy_check method to correctly handle role mentions and streamline role name checks, improving user interaction and validation logic.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
This commit is contained in:
parent
85de2c70c1
commit
35e0ac182d
1 changed files with 10 additions and 4 deletions
14
shop/shop.py
14
shop/shop.py
|
@ -1495,14 +1495,20 @@ class ItemManager:
|
|||
return int(cost.content)
|
||||
|
||||
def hierarchy_check(self, m):
|
||||
# Extract role ID from mention if it's a mention
|
||||
if m.role_mentions:
|
||||
role = m.role_mentions[0]
|
||||
if self.ctx.author == m.author:
|
||||
if self.ctx.author.top_role >= role:
|
||||
return True
|
||||
return False
|
||||
|
||||
# Regular role name check
|
||||
roles = [r.name for r in self.ctx.guild.roles if r.name != "Bot"]
|
||||
if self.ctx.author == m.author and m.content in roles:
|
||||
if self.ctx.author.top_role >= discord.utils.get(self.ctx.message.guild.roles, name=m.content):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
async def set_role(self, item=None, shop=None):
|
||||
await self.ctx.send(
|
||||
|
|
Loading…
Add table
Reference in a new issue