예제 #1
0
def _format_missing_required_arg(ctx, param):
    required, optional = _split_params(ctx.command)
    missing = list(itertools.dropwhile(lambda p: p != param, required))
    names = human_join(f'`{p.name}`' for p in missing)
    example = ' '.join(
        _parameter_examples(missing + _random_slice(optional), ctx))

    # TODO: Specify the args more descriptively.
    return (f"Hey hey, you're missing {names}.\n\n"
            f'Usage: `{ctx.clean_prefix}{ctx.command.signature}`\n'
            f'Example: {ctx.message.clean_content} **{example}** \n')
예제 #2
0
def _format_converters(converters):
    # Right now the only things I have are "int", "Member", and the channels.
    # When I make typing.Union a normal thing (which might never happen because
    # of disambiguation), this probably won't be as hacky.

    if all(
            inspect.isclass(c) and issubclass(c, discord.abc.GuildChannel)
            for c in converters):
        return 'channel'

    return human_join(map(_format_converter, converters), final='or')
예제 #3
0
def _format_bot_missing_perms(ctx, missing_perms):
    action = _missing_perm_actions.get(str(ctx.command))
    if not action:
        actions = (_DEFAULT_MISSING_PERMS_ACTIONS.get(p, p.replace('_', ' '))
                   for p in missing_perms)
        action = human_join(actions, final='or')

    nice_perms = (perm.replace('_', ' ').replace('guild', 'server').title()
                  for perm in missing_perms)

    return (f"Hey hey, I don't have permissions to {action}. "
            f'Please check if I have {human_join(nice_perms)}.')
예제 #4
0
    def bot_missing_perms(self, missing_perms):
        """Send a message that the bot is missing permssions.

        If action is not specified the actions for each permissions are used.
        """
        action = _missing_perm_actions.get(str(self.command))
        if not action:
            actions = (_DEFAULT_MISSING_PERMS_ACTIONS.get(
                p, p.replace('_', ' ')) for p in missing_perms)
            action = human_join(actions, final='or')

        nice_perms = (perm.replace('_', ' ').replace('guild',
                                                     'server').title()
                      for perm in missing_perms)

        message = (f"Hey hey, I don't have permissions to {action}. "
                   f'Please check if I have {human_join(nice_perms)}.')

        return self.send(message)