added removeal of selfrole command to override it

This commit is contained in:
brandons209 2020-01-30 22:21:49 -05:00
parent 54c72d8369
commit 4653cf2364

View file

@ -83,6 +83,8 @@ class RoleManagement(
self._start_task: Optional[asyncio.Task] = None self._start_task: Optional[asyncio.Task] = None
self.loop = asyncio.get_event_loop() self.loop = asyncio.get_event_loop()
self._sub_task = self.loop.create_task(self.sub_checker()) self._sub_task = self.loop.create_task(self.sub_checker())
# remove selfrole commands since we are going to override them
self.bot.remove_command("selfrole")
super().__init__() super().__init__()
def cog_unload(self): def cog_unload(self):
@ -668,15 +670,15 @@ class RoleManagement(
@checks.bot_has_permissions(manage_roles=True) @checks.bot_has_permissions(manage_roles=True)
@commands.guild_only() @commands.guild_only()
@commands.group(name="srole", autohelp=True) @commands.group(name="selfrole", autohelp=True)
async def srole(self, ctx: GuildContext): async def selfrole(self, ctx: GuildContext):
""" """
Self assignable role commands Self assignable role commands
""" """
pass pass
@srole.command(name="list") @selfrole.command(name="list")
async def srole_list(self, ctx: GuildContext): async def selfrole_list(self, ctx: GuildContext):
""" """
Lists the selfroles and any associated costs. Lists the selfroles and any associated costs.
""" """
@ -715,8 +717,8 @@ class RoleManagement(
await ctx.send(embed=embed) await ctx.send(embed=embed)
@srole.command(name="buy") @selfrole.command(name="buy")
async def srole_buy(self, ctx: GuildContext, *, role: discord.Role): async def selfrole_buy(self, ctx: GuildContext, *, role: discord.Role):
""" """
Purchase a role Purchase a role
""" """
@ -737,7 +739,7 @@ class RoleManagement(
return await ctx.send(f"You aren't allowed to add `{role}` to yourself {ctx.author.mention}!") return await ctx.send(f"You aren't allowed to add `{role}` to yourself {ctx.author.mention}!")
if not cost: if not cost:
return await ctx.send("This role doesn't have a cost. Please try again using `[p]srole add`.") return await ctx.send("This role doesn't have a cost. Please try again using `[p]selfrole add`.")
free_roles = await self.config.guild(ctx.guild).free_roles() free_roles = await self.config.guild(ctx.guild).free_roles()
currency_name = await bank.get_currency_name(ctx.guild) currency_name = await bank.get_currency_name(ctx.guild)
@ -764,7 +766,7 @@ class RoleManagement(
await self.update_roles_atomically(who=ctx.author, give=[role], remove=remove) await self.update_roles_atomically(who=ctx.author, give=[role], remove=remove)
await ctx.tick() await ctx.tick()
@srole.command(name="add") @selfrole.command(name="add")
async def sadd(self, ctx: GuildContext, *, role: discord.Role): async def sadd(self, ctx: GuildContext, *, role: discord.Role):
""" """
Join a role Join a role
@ -785,12 +787,12 @@ class RoleManagement(
await ctx.send(f"You aren't allowed to add `{role}` to yourself {ctx.author.mention}!") await ctx.send(f"You aren't allowed to add `{role}` to yourself {ctx.author.mention}!")
elif cost: elif cost:
await ctx.send("This role is not free. " "Please use `[p]srole buy` if you would like to purchase it.") await ctx.send("This role is not free. " "Please use `[p]selfrole buy` if you would like to purchase it.")
else: else:
await self.update_roles_atomically(who=ctx.author, give=[role], remove=remove) await self.update_roles_atomically(who=ctx.author, give=[role], remove=remove)
await ctx.tick() await ctx.tick()
@srole.command(name="remove") @selfrole.command(name="remove")
async def srem(self, ctx: GuildContext, *, role: discord.Role): async def srem(self, ctx: GuildContext, *, role: discord.Role):
""" """
leave a role leave a role