More commands
This commit is contained in:
parent
2d1f7495a3
commit
133048120f
@ -33,27 +33,34 @@ class ReginaldCog(commands.Cog):
|
||||
allowed_roles = await self.config.guild(ctx.guild).allowed_roles()
|
||||
return any(role.id in allowed_roles for role in ctx.author.roles)
|
||||
|
||||
@commands.guild_only()
|
||||
@commands.command(name="reginald_allowrole", help="Allow a role to use the Reginald command")
|
||||
async def allowrole(self, ctx, role: discord.Role):
|
||||
if not await self.has_admin_role(ctx):
|
||||
await ctx.send("You do not have the required permissions to use this command.")
|
||||
return
|
||||
@commands.command(name="allowrole")
|
||||
@commands.has_permissions(administrator=True)
|
||||
async def allow_role(self, ctx, role: discord.Role):
|
||||
"""Allows a role to use the reginald command"""
|
||||
async with self.config.guild(ctx.guild).allowed_roles() as allowed_roles:
|
||||
if role.id not in allowed_roles:
|
||||
allowed_roles.append(role.id)
|
||||
await ctx.send(f"Role {role.name} is now allowed to use the Reginald command.")
|
||||
await ctx.send(f"The {role.name} role is now allowed to use the Reginald command.")
|
||||
else:
|
||||
await ctx.send(f"The {role.name} role is already allowed to use the Reginald command.")
|
||||
|
||||
|
||||
@commands.guild_only()
|
||||
@commands.command(name="reginald_disallowrole", help="Remove a role's ability to use the Reginald command")
|
||||
async def disallowrole(self, ctx, role: discord.Role):
|
||||
if not await self.has_admin_role(ctx):
|
||||
await ctx.send("You do not have the required permissions to use this command.")
|
||||
return
|
||||
@commands.command(name="disallowrole")
|
||||
@commands.has_permissions(administrator=True)
|
||||
async def disallow_role(self, ctx, role: discord.Role):
|
||||
"""Revokes a role's permission to use the reginald command"""
|
||||
async with self.config.guild(ctx.guild).allowed_roles() as allowed_roles:
|
||||
if role.id in allowed_roles:
|
||||
allowed_roles.remove(role.id)
|
||||
await ctx.send(f"Role {role.name} is no longer allowed to use the Reginald command.")
|
||||
await ctx.send(f"The {role.name} role is no longer allowed to use the Reginald command.")
|
||||
else:
|
||||
await ctx.send(f"The {role.name} role is not currently allowed to use the Reginald command.")
|
||||
|
||||
def role_check():
|
||||
async def predicate(ctx):
|
||||
allowed_roles = await ctx.bot.get_cog("ReginaldCog").config.guild(ctx.guild).allowed_roles()
|
||||
return any(role.id in allowed_roles for role in ctx.author.roles)
|
||||
return commands.check(predicate)
|
||||
|
||||
@commands.guild_only()
|
||||
@commands.has_permissions(manage_guild=True)
|
||||
@ -63,7 +70,7 @@ class ReginaldCog(commands.Cog):
|
||||
await ctx.send("OpenAI API key set successfully.")
|
||||
|
||||
@commands.guild_only()
|
||||
@has_allowed_role()
|
||||
@role_check()
|
||||
@commands.command(help="Ask Reginald a question")
|
||||
@commands.cooldown(1, 10, commands.BucketType.user) # 10 second cooldown per user
|
||||
async def reginald(self, ctx, *, prompt=None):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user