예제 #1
0
파일: bot.py 프로젝트: starwiz-7/HackBot
 def no_dm_check(ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage('No Private Hacking!!')
     return True
예제 #2
0
 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
예제 #3
0
    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
예제 #4
0
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
예제 #5
0
파일: checks.py 프로젝트: Shirataki2/konoha
 def predicate(ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage()
     _bot_has_permissions(ctx, kick_members=True)
     return True
예제 #6
0
async def is_allowed_in_all_guild_channels(context):
    if context.channel.type.name == 'private':
        raise commands.NoPrivateMessage()
    return True
예제 #7
0
 def predicate(ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage()
     return True
예제 #8
0
 async def __local_check(ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage(
             "Settings can't be modified on private messages.")
     return True
예제 #9
0
 def cog_check(self, ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage(
             "This command can only be used within a guild")
     return True
예제 #10
0
 async def cog_check(self, ctx):
     if not ctx.guild:
         raise commands.NoPrivateMessage(
             'This command cannot be used in private messages.')
     return True
예제 #11
0
 def cog_check(self, ctx: commands.Context):
     if not ctx.guild:
         raise commands.NoPrivateMessage("This command can not be used in DMs.")
     return True
예제 #12
0
    def cog_check(self, ctx: commands.Context):
        if not ctx.guild:
            raise commands.NoPrivateMessage('xD go get in a server silly!')

        return True
예제 #13
0
 def cog_check(self, ctx):
     if ctx.guild is None:
         raise dpy_commands.NoPrivateMessage(
             "Moderation commands can't be used in DMs")
     return True
예제 #14
0
    def cog_check(self, ctx: commands.Context):
        if not ctx.guild:
            raise commands.NoPrivateMessage(
                'Bu komut özel mesaj olarak kullanılamaz')

        return True
예제 #15
0
파일: tags.py 프로젝트: nwunderly/RevBots
 async def cog_check(self, ctx):
     if not ctx.guild:
         raise commands.NoPrivateMessage("Tag commands cannot be used in DMs")
     else:
         return True
예제 #16
0
 def __local_check(self, ctx):
     if not ctx.guild:
         raise commands.NoPrivateMessage(
             '**This command cannot be used in a private message.**')
     return True
예제 #17
0
 def cog_check(self, ctx):
     """Check function called before any command of the cog."""
     if ctx.guild is None:
         raise commands.NoPrivateMessage()
     return True
예제 #18
0
파일: bot.py 프로젝트: sasha-sem/bot-clown
 def cog_check(self, ctx: commands.Context):
     if not ctx.guild:
         raise commands.NoPrivateMessage('Эту команду нельзя использовать в личке.')
     return True
예제 #19
0
 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
예제 #20
0
 async def predicate(ctx):
     if not ctx.guild:
         raise commands.NoPrivateMessage()
     if ctx.guild.owner != ctx.author:
         raise NotGuildOwner()
     return True
예제 #21
0
 def cog_check(self, ctx):
     if not ctx.guild:
         raise commands.NoPrivateMessage()
     if ctx.guild.owner != ctx.author:
         raise base.NotGuildOwner()
     return True
예제 #22
0
    def cog_check(self, ctx: commands.Context):
        if not ctx.guild:
            raise commands.NoPrivateMessage('Questo comando non può essere usato in DM')

        return True
예제 #23
0
파일: main.py 프로젝트: Drain79/lotro
async def globally_block_dms(ctx):
    if ctx.guild is None:
        raise commands.NoPrivateMessage("No dm allowed!")
    else:
        return True
예제 #24
0
 async def cog_check(self, ctx: KurisuContext):
     if ctx.guild is None and ctx.command.name != "listwarns":
         raise commands.NoPrivateMessage()
     return True
예제 #25
0
파일: checks.py 프로젝트: Shirataki2/konoha
 def predicate(ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage()
     _has_permissions(ctx, manage_messages=True)
     return True
예제 #26
0
 def no_dm_check(ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage('Private messages not permitted.')
     return True
예제 #27
0
 async def cog_check(self, ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage()
     return True
예제 #28
0
 def no_dm_check(ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage("I refuse.")
     return True
예제 #29
0
 def __local_check(self, ctx):
     if ctx.guild is None:
         raise commands.NoPrivateMessage(
             'This command cannot be used in private messages.')
     return True
예제 #30
0
파일: __main__.py 프로젝트: t41y0u/amiya
 def no_dm_check(ctx):
     """ Check for DMs """
     if ctx.guild is None:
         raise commands.NoPrivateMessage("Private messages not permitted.")
     return True