async def cog_check(self, ctx): if ctx.guild is None: raise commands.NoPrivateMessage() elif (not await self.bot.is_owner(ctx.author) and not ctx.channel.permissions_for( ctx.message.author).administrator): raise utils.CustomError( 'You must be an administrator to use this command.') return True
async def convert(self, ctx, argument): if not self.case_sensitive: argument = argument.lower() if argument not in self.accepted: parameter = list(ctx.command.clean_params.keys())[len( ctx.args) - 2] # -2 removes Cog and Context object if not self.has_default: raise utils.CustomError( f'Parameter `{parameter}` must be one of the following: {", ".join(self.accepted)} ' f'({"not " if not self.case_sensitive else ""}case sensitive)' ) return argument
async def bot_check_once(self, ctx): if ctx.guild is None: return True options = self.bot.guild_options[ctx.guild.id] if (ctx.command.parent is not None and ctx.command.parent.name in options['disabled_commands'] or ctx.command.qualified_name in options['disabled_commands'] or ctx.command.cog.qualified_name in options['disabled_cogs']): if (not await self.bot.is_owner(ctx.author) and not ctx.channel.permissions_for(ctx.message.author).administrator): raise utils.CustomError('This command or its category has been disabled in this server.') else: await utils.confirm(ctx, 'This command or its category has been disabled in this server. Override?') return True
async def confirm(ctx, text, timeout=30): message = await ctx.send(f'{text}') await message.add_reaction('<:yes:651325958514802689>') await message.add_reaction('<:no:653131696169811979>') def check(reaction, user): return reaction.emoji.id in [651325958514802689, 653131696169811979] and user.id == ctx.author.id try: reaction, user = await ctx.bot.wait_for('reaction_add', check=check, timeout=timeout) except asyncio.TimeoutError: raise utils.CustomError('Did not receive a response in time, aborting action.') else: if reaction.emoji.id == 653131696169811979: await message.edit(content='Aborted.') raise utils.SilentError()