def no_dm_check(ctx): if ctx.guild is None: raise commands.NoPrivateMessage('No Private Hacking!!') return True
def predicate(ctx): if not ctx.guild: raise commands.NoPrivateMessage() elif ctx.guild.id != must_be_in_guild_id: raise NotInServer(must_be_in_guild_id=must_be_in_guild_id) return True
def cog_check(self, ctx: commands.Context): if not ctx.guild: raise commands.NoPrivateMessage('This command can\'t be used in DM channels.') return True
async def option_picker(ctx, *options, timeout: float = 300, formatter=option_picker_formatter, option_formatter=str, max_lines: int = 6) -> typing.Any: """ Displays a list of options, enabling the user to pick one by providing input. If the user closes the pagination of options, we assume this to be closing the option picker, and we return None. If timeout is reached, we return None. :param ctx: the command context, or a tuple of bot, message, and channel :param options: the options to show. :param timeout: timeout to wait for before killing the prompt. :param formatter: the formatter for each page of options. :param option_formatter: the formatter to use to get what to display for each option. :param max_lines: the max lines to show per page. """ if isinstance(ctx, commands.Context): bot, message, channel = ctx.bot, ctx.message, ctx.channel else: bot, message, channel = ctx if message.guild is None: raise commands.NoPrivateMessage('Option pickers will not work in DMs.') binder = bookbinding.StringBookBinder(ctx, max_lines=max_lines, timeout=None) binder.with_page_number_formatter(formatter) for i, option in enumerate(options): binder.add_line(f'{i + 1} - {option_formatter(option)!s}', dont_alter=True) book = binder.build() async def run_options_view(): await book.start() raise ClosedInterrupt def predicate(response): return response.author == message.author and \ response.channel == message.channel async def get_option(): # Raises a ResultPickedInterrupt when finished. user_input = None while user_input is None: m = await bot.wait_for('message', check=predicate, timeout=timeout) content = m.content try: option_num = int(content) if option_num < 1 or option_num > len(options): raise IndexError except IndexError: await channel.send('Out of range', delete_after=5) continue except ValueError: await channel.send('Cancelling...', delete_after=5) await helpers.attempt_delete(m) raise ClosedInterrupt else: await helpers.attempt_delete(m) raise ResultPickedInterrupt(options[option_num - 1]) try: option, _ = await asyncio.gather(get_option(), run_options_view()) except ResultPickedInterrupt as result: return result.result except ClosedInterrupt: return None except asyncio.TimeoutError: return None except discord.Forbidden as ex: raise ex from None finally: try: if book.is_running(): await book.delete() await book.__aexit__(None, None, None) except: pass
def predicate(ctx): if ctx.guild is None: raise commands.NoPrivateMessage() _bot_has_permissions(ctx, kick_members=True) return True
async def is_allowed_in_all_guild_channels(context): if context.channel.type.name == 'private': raise commands.NoPrivateMessage() return True
def predicate(ctx): if ctx.guild is None: raise commands.NoPrivateMessage() return True
async def __local_check(ctx): if ctx.guild is None: raise commands.NoPrivateMessage( "Settings can't be modified on private messages.") return True
def cog_check(self, ctx): if ctx.guild is None: raise commands.NoPrivateMessage( "This command can only be used within a guild") return True
async def cog_check(self, ctx): if not ctx.guild: raise commands.NoPrivateMessage( 'This command cannot be used in private messages.') return True
def cog_check(self, ctx: commands.Context): if not ctx.guild: raise commands.NoPrivateMessage("This command can not be used in DMs.") return True
def cog_check(self, ctx: commands.Context): if not ctx.guild: raise commands.NoPrivateMessage('xD go get in a server silly!') return True
def cog_check(self, ctx): if ctx.guild is None: raise dpy_commands.NoPrivateMessage( "Moderation commands can't be used in DMs") return True
def cog_check(self, ctx: commands.Context): if not ctx.guild: raise commands.NoPrivateMessage( 'Bu komut özel mesaj olarak kullanılamaz') return True
async def cog_check(self, ctx): if not ctx.guild: raise commands.NoPrivateMessage("Tag commands cannot be used in DMs") else: return True
def __local_check(self, ctx): if not ctx.guild: raise commands.NoPrivateMessage( '**This command cannot be used in a private message.**') return True
def cog_check(self, ctx): """Check function called before any command of the cog.""" if ctx.guild is None: raise commands.NoPrivateMessage() return True
def cog_check(self, ctx: commands.Context): if not ctx.guild: raise commands.NoPrivateMessage('Эту команду нельзя использовать в личке.') return True
def cog_check(self, ctx): """Extra checks for the cog's commands.""" if not ctx.guild: raise commands.NoPrivateMessage( 'This command cannot be used in a private message.') return True
async def predicate(ctx): if not ctx.guild: raise commands.NoPrivateMessage() if ctx.guild.owner != ctx.author: raise NotGuildOwner() return True
def cog_check(self, ctx): if not ctx.guild: raise commands.NoPrivateMessage() if ctx.guild.owner != ctx.author: raise base.NotGuildOwner() return True
def cog_check(self, ctx: commands.Context): if not ctx.guild: raise commands.NoPrivateMessage('Questo comando non può essere usato in DM') return True
async def globally_block_dms(ctx): if ctx.guild is None: raise commands.NoPrivateMessage("No dm allowed!") else: return True
async def cog_check(self, ctx: KurisuContext): if ctx.guild is None and ctx.command.name != "listwarns": raise commands.NoPrivateMessage() return True
def predicate(ctx): if ctx.guild is None: raise commands.NoPrivateMessage() _has_permissions(ctx, manage_messages=True) return True
def no_dm_check(ctx): if ctx.guild is None: raise commands.NoPrivateMessage('Private messages not permitted.') return True
async def cog_check(self, ctx): if ctx.guild is None: raise commands.NoPrivateMessage() return True
def no_dm_check(ctx): if ctx.guild is None: raise commands.NoPrivateMessage("I refuse.") return True
def __local_check(self, ctx): if ctx.guild is None: raise commands.NoPrivateMessage( 'This command cannot be used in private messages.') return True
def no_dm_check(ctx): """ Check for DMs """ if ctx.guild is None: raise commands.NoPrivateMessage("Private messages not permitted.") return True