From 4b78564aaf997c64eb6faf6086846bfd79378abb Mon Sep 17 00:00:00 2001 From: TrustyJAID Date: Sun, 15 Dec 2024 12:01:00 -0700 Subject: [PATCH] [RoleTools] 1.5.16 Fix selfrole checks - Remove early checks in `[p]roletools selfrole` for requirements and cost since they're already handled in the giverole function. - This also fixes an issue where give_role might not have actually given the role causing the user to receive a message stating they got the role when they didn't. --- README.md | 2 +- roletools/roletools.py | 44 ++++++++++++------------------------------ 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 1b769c540..0c2cada3a 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ TrustyJAID's Cogs for [Red-DiscordBot](https://github.com/Cog-Creators/Red-Disc | Reddit | 1.2.0 |
A cog to post updates from reddit.Reddit commands for getting updates on specified subreddits.
| TrustyJAID | | Rekt | 1.0.0 |
Get REKTAre you REKT?
| TrustyJAID | | ReTrigger | 2.29.1 |
Trigger events via Regular Expressions!Trigger events based on regex! Check out and for help setting up the cog. Note: This cog can become quite resource heavy. Optional features are available if the requirements are present such as pillow for image resizing and pytesseract to scan images for text (OCR).
| TrustyJAID | -| RoleTools | 1.5.15 |
Various role related tools.Various role utility commands. Including Reaction roles, Sticky roles, and Auto role.
| TrustyJAID | +| RoleTools | 1.5.16 |
Various role related tools.Various role utility commands. Including Reaction roles, Sticky roles, and Auto role.
| TrustyJAID | | runescape | 1.5.2 |
Show your Runescape stats in discord!A cog to grab Runescape and OSRS stats and profile information.
| TrustyJAID | | ServerStats | 1.8.0 |
A plethora of potentially useful commands for any bot owner.A plethora of potentially useful commands for any bot owner. Includes a way to track the bot joining new servers, find cheaters on global economies, get user avatars and even larger emojis.
| TrustyJAID and Preda | | Spotify | 1.7.3 |
Control Spotify through Discord!This cog allows you to control Spotify via OAuth through the bot on discord. Use `[p]spotify` to see available commands.
| TrustyJAID and NeuroAssassin | diff --git a/roletools/roletools.py b/roletools/roletools.py index 29cbf385d..70e91e3cf 100644 --- a/roletools/roletools.py +++ b/roletools/roletools.py @@ -85,7 +85,7 @@ class RoleTools( """ __author__ = ["TrustyJAID"] - __version__ = "1.5.15" + __version__ = "1.5.16" def __init__(self, bot: Red): self.bot = bot @@ -280,57 +280,37 @@ async def selfrole(self, ctx: Context, *, role: SelfRoleConverter) -> None: else: await self.selfrole_remove(ctx, role=role) - async def selfrole_add(self, ctx: Context, *, role: SelfRoleConverter) -> None: + async def selfrole_add(self, ctx: Context, *, role: discord.Role) -> None: """ Give yourself a role `` The role you want to give yourself """ await ctx.typing() - author = ctx.author + author: discord.Member = ctx.author if not await self.config.role(role).selfassignable(): msg = _("The {role} role is not currently selfassignable.").format(role=role.mention) await ctx.send(msg) return - if required := await self.config.role(role).required(): - has_required = True - for role_id in required: - r = ctx.guild.get_role(role_id) - if r is None: - async with self.config.role(role).required() as required_roles: - required_roles.remove(role_id) - continue - if r not in author.roles: - has_required = False - if not has_required: - msg = _( - "I cannot grant you the {role} role because you " - "are missing a required role." - ).format(role=role.mention) - await ctx.send(msg) - return - if cost := await self.config.role(role).cost(): - currency_name = await bank.get_currency_name(ctx.guild) - if not await bank.can_spend(author, cost): - msg = _( - "You do not have enough {currency_name} to acquire " - "this role. You need {cost} {currency_name}." - ).format(currency_name=currency_name, cost=cost) - await ctx.send(msg) - return - await self.give_roles(author, [role], _("Selfrole command.")) + response = await self.give_roles(author, [role], _("Selfrole command.")) + if response: + msg = _("I could not assign that role for the following reasons:\n") + for r in response: + msg += r.reason + await ctx.send(msg) + return msg = _("You have been given the {role} role.").format(role=role.mention) await ctx.send(msg) - async def selfrole_remove(self, ctx: Context, *, role: SelfRoleConverter) -> None: + async def selfrole_remove(self, ctx: Context, *, role: discord.Role) -> None: """ Remove a role from yourself `` The role you want to remove. """ await ctx.typing() - author = ctx.author + author: discord.Member = ctx.author if not await self.config.role(role).selfremovable(): msg = _("The {role} role is not currently self removable.").format(role=role.mention)