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
12
shop/shop.py
12
shop/shop.py
|
@ -1495,13 +1495,19 @@ class ItemManager:
|
||||||
return int(cost.content)
|
return int(cost.content)
|
||||||
|
|
||||||
def hierarchy_check(self, m):
|
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"]
|
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 == m.author and m.content in roles:
|
||||||
if self.ctx.author.top_role >= discord.utils.get(self.ctx.message.guild.roles, name=m.content):
|
if self.ctx.author.top_role >= discord.utils.get(self.ctx.message.guild.roles, name=m.content):
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def set_role(self, item=None, shop=None):
|
async def set_role(self, item=None, shop=None):
|
||||||
|
|
Loading…
Add table
Reference in a new issue