diff --git a/Commands/help.py b/Commands/help.py index 6cc56b1..5a3d9b3 100644 --- a/Commands/help.py +++ b/Commands/help.py @@ -28,7 +28,7 @@ async def help(self, ctx, value: str = None): embed.set_thumbnail(url=self.client.user.avatar_url) embed.add_field(name="📷 Profile", value=f"`Profile Customisation`") embed.add_field(name="😃 Fun", value=f"`Fun Commands`") - if ctx.author.guild_permissions.administrator: + if ctx.author.guild_permissions.administrator or ctx.author.id == int(config["Bot_Owner"]): embed.add_field(name="🔧 Admin", value=f"`Admin Commands`") if ctx.author.id == int(config["Bot_Owner"]): embed.add_field(name="💼 Owner", value=f"`Owner Commands`") @@ -40,7 +40,7 @@ async def help(self, ctx, value: str = None): await msg.add_reaction("😃") if ctx.author.id == int(config["Bot_Owner"]): await msg.add_reaction("💼") - if ctx.author.guild_permissions.administrator: + if ctx.author.guild_permissions.administrator or ctx.author.id == int(config["Bot_Owner"]): await msg.add_reaction("🔧") if os.path.isfile("Addons/Extras.py"): await msg.add_reaction("🔗") diff --git a/Commands/role.py b/Commands/role.py index 77b3089..5299de2 100644 --- a/Commands/role.py +++ b/Commands/role.py @@ -9,6 +9,7 @@ import KumosLab.Database.remove from discord.ext.commands import RoleNotFound +from discord.ext.commands import has_permissions, CheckFailure import vacefron @@ -17,36 +18,42 @@ config = yaml.load(file) - # Roles Class class role(commands.Cog): def __init__(self, client): self.client = client # Role Command - @commands.command() + @commands.command(pass_context=True) + @has_permissions(manage_roles=True) async def role(self, ctx, state: str = None, role_name: discord.Role = None, role_level: int = None): if state is None: - embed = discord.Embed(description=f"🔴 **ERROR**: `You must define add or remove! - {config['Prefix']}role `") + embed = discord.Embed( + description=f"🔴 **ERROR**: `You must define add or remove! - {config['Prefix']}role `") await ctx.reply(embed=embed) return if role is None: - embed = discord.Embed(description=f"🔴 **ERROR**: `You must define a role! - {config['Prefix']}role `") + embed = discord.Embed( + description=f"🔴 **ERROR**: `You must define a role! - {config['Prefix']}role `") await ctx.send(embed=embed) return if role_level is None: - embed = discord.Embed(description=f"🔴 **ERROR**: `You must define a role level! - {config['Prefix']}role `") + embed = discord.Embed( + description=f"🔴 **ERROR**: `You must define a role level! - {config['Prefix']}role `") await ctx.send(embed=embed) return try: if state.lower() == "add": - exists = await KumosLab.Database.add.role(guild=ctx.guild, role_name=role_name, role_level=int(role_level)) + exists = await KumosLab.Database.add.role(guild=ctx.guild, role_name=role_name, + role_level=int(role_level)) if exists == "error": - embed = discord.Embed(description=f"🔴 **ERROR**: `Role already exists! - {config['Prefix']}role `") + embed = discord.Embed( + description=f"🔴 **ERROR**: `Role already exists! - {config['Prefix']}role `") await ctx.reply(embed=embed) return else: - embed = discord.Embed(description=f"🟢 **SUCCESS**: `Added {role_name} to unlock at Level {role_level}`") + embed = discord.Embed( + description=f"🟢 **SUCCESS**: `Added {role_name} to unlock at Level {role_level}`") await ctx.reply(embed=embed) elif state.lower() == "remove": await KumosLab.Database.remove.role(guild=ctx.guild, role_name=role_name, role_level=int(role_level)) @@ -55,10 +62,20 @@ async def role(self, ctx, state: str = None, role_name: discord.Role = None, rol await ctx.reply(embed=embed) except RoleNotFound as e: - embed = discord.Embed(description=f"🔴 **ERROR**: `Role not found! - {config['Prefix']}role `") + embed = discord.Embed( + description=f"🔴 **ERROR**: `Role not found! - {config['Prefix']}role `") await ctx.send(embed=embed) return + @role_add.error + async def role_add_error(self, error, ctx): + if isinstance(error, CheckFailure): + embed = discord.Embed( + title=":x: Error", description="Looks like you don't have the permission to create new unlockable " + "roles! **Required Permission:** Manage Roles", color=config[ + "error_embed_colour"]) + await ctx.reply(embed=embed) + # Role List Command @commands.command() async def roles(self, ctx): @@ -70,29 +87,35 @@ async def roles(self, ctx): embed.add_field(name="Level:", value="`No level required!`") else: embed.add_field(name="Roles:", value=f"`{str(role_array).replace('[', '').replace(']', '')}`") - embed.add_field(name="Level:", value=f"`{str(role_level_array).replace('[', '').replace(']', '')}`", inline=False) + embed.add_field(name="Level:", value=f"`{str(role_level_array).replace('[', '').replace(']', '')}`", + inline=False) await ctx.send(embed=embed) @commands.command() async def creator(self, ctx, amount: int = None, prefix: str = None): if amount is None: - embed = discord.Embed(description=f"🔴 **ERROR**: `You must define a amount! - {config['Prefix']}creator `") + embed = discord.Embed( + description=f"🔴 **ERROR**: `You must define a amount! - {config['Prefix']}creator `") await ctx.reply(embed=embed) return if prefix is None: - embed = discord.Embed(description=f"🔴 **ERROR**: `You must define a role-prefix! - {config['Prefix']}creator `") + embed = discord.Embed( + description=f"🔴 **ERROR**: `You must define a role-prefix! - {config['Prefix']}creator `") await ctx.reply(embed=embed) return if amount > 50 or amount < 1: - embed = discord.Embed(description=f"🔴 **ERROR**: `You can only create 50 roles at a time! - {config['Prefix']}creator `") + embed = discord.Embed( + description=f"🔴 **ERROR**: `You can only create 50 roles at a time! - {config['Prefix']}creator `") await ctx.reply(embed=embed) return if len(prefix) > 10 or len(prefix) < 1: - embed = discord.Embed(description=f"🔴 **ERROR**: `You can only create a prefix with 10 characters! - {config['Prefix']}creator `") + embed = discord.Embed( + description=f"🔴 **ERROR**: `You can only create a prefix with 10 characters! - {config['Prefix']}creator `") await ctx.reply(embed=embed) return # loop amount of times - message = await ctx.send(f"🔓 **CREATING ROLES**: `Creating {amount} roles with prefix {prefix}. Please wait, this may take some time...`") + message = await ctx.send( + f"🔓 **CREATING ROLES**: `Creating {amount} roles with prefix {prefix}. Please wait, this may take some time...`") for i in range(amount): # create role role = await ctx.guild.create_role(name=f"{prefix} {i + 1}") @@ -102,15 +125,6 @@ async def creator(self, ctx, amount: int = None, prefix: str = None): await message.edit(content=f"🔓 **CREATING ROLES**: `Created {amount} roles with prefix {prefix}.`") - - - - - - - - - # Sets-up the cog for roles def setup(client): client.add_cog(role(client))