async def shutdown(self, ctx): if not sql.isOwner(ctx.author): return await ctx.send(embed=func.NoPerm()) await ctx.send("Shutting down...") await self.bot.logout()
async def cog(self, ctx): if not sql.isOwner(ctx.author.id): return await ctx.send(embed=func.NoPerm()) await ctx.send(embed=func.Embed( "**cog load** - Load a cog.\n**cog unload** - Unload a cog.\n**cog reload** - Reload a cog\n**cog list** - Lists all cogs." ))
async def add(self, ctx, user: discord.User = None, access: str = None): types = ['owner', 'admin'] if not sql.isOwner(ctx.author.id): return await ctx.send(embed=func.NoPerm()) if not user or not access: return await ctx.send( embed=func.ErrorEmbed(f"Mention a user & access rank")) if access not in types: return await ctx.send( embed=func.ErrorEmbed(f"Please type 'admin' or 'owner'")) if access == 'owner': type = 2 elif access == 'admin': type = 1 if not sql.isStaff(user): if sql.SetAccess(user, type): await ctx.send( embed=func.Embed(f"Gave {user.mention} {access}.")) else: await ctx.send(embed=func.ErrorEmbed( "Something went wrong. Please try again")) else: await ctx.send( embed=func.ErrorEmbed("That user already has access rights"))
async def access(self, ctx): if not sql.isOwner(ctx.author.id): return await ctx.send(embed=func.NoPerm()) await ctx.send(embed=func.ErrorEmbed( f"Usage:\n\n{ctx.prefix}access add @user [Type]\n{ctx.prefix}access remove @user\n{ctx.prefix}access list\n\n Access Types: admin & owner" ))
async def list(self, ctx): if not sql.isOwner(ctx.author.id): return await ctx.send(embed=func.NoPerm()) cogs = [] for file in os.listdir("modules"): if file.endswith(".py"): name = file[:-3] cogs.append(name) await ctx.send(embed=func.Embed("\n".join(cogs)))
async def load(self, ctx, cog: str = None): if not sql.isOwner(ctx.author.id): return await ctx.send(embed=func.NoPerm()) if not cog: await ctx.send(embed=func.ErrorEmbed("Please name a cog to load")) try: self.bot.load_extension(f"modules.cogs.{cog}") await ctx.send(embed=func.Embed(f"{cog} was successfully loaded.")) except Exception as error: await ctx.send(embed=func.ErrorEmbed(f"{cog} failed to load")) await ctx.author.send(error)
async def remove(self, ctx, user: discord.User = None): if not sql.isOwner(ctx.author.id): return await ctx.send(embed=func.NoPerm()) if not user: return await ctx.send(embed=func.ErrorEmbed(f"Mention a user")) if sql.isStaff(user): if sql.DelAccess(user): await ctx.send( embed=func.Embed(f"Removed {user.mention}'s rights")) else: await ctx.send(embed=func.ErrorEmbed( "Something went wrong. Please try again")) else: await ctx.send( embed=func.ErrorEmbed("That user has no access rights"))
async def unload(self, ctx, cog: str = None): if not sql.isOwner(ctx.author.id): return await ctx.send(embed=func.NoPerm()) if not cog: return await ctx.send( embed=func.ErrorEmbed("Please name a cog to load")) if cog == "Commands": return await ctx.send( embed=func.ErrorEmbed("That is a required cog. Try another")) try: self.bot.unload_extension(f"modules.{cog}") await ctx.send( embed=func.Embed(f"{cog} was successfully unloaded.")) except Exception as error: await ctx.send(embed=func.ErrorEmbed(f"{cog} failed to unload")) func.log(error)
async def list(self, ctx): if not sql.isOwner(ctx.author.id): return await ctx.send(embed=func.NoPerm()) unformatted = sql.getallAccess() formatted = [] for i in unformatted: user = await self.bot.fetch_user(i[0]) if i[1] == 1: type = "Admin Access" if i[1] == 2: type = "Owner Access" formatted.append(f"{user.mention} - {type}") await ctx.send(embed=func.Embed("\n".join(formatted)))