当前位置: 首页>>代码示例>>Python>>正文


Python commands.MissingRequiredArgument方法代码示例

本文整理汇总了Python中discord.ext.commands.MissingRequiredArgument方法的典型用法代码示例。如果您正苦于以下问题:Python commands.MissingRequiredArgument方法的具体用法?Python commands.MissingRequiredArgument怎么用?Python commands.MissingRequiredArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord.ext.commands的用法示例。


在下文中一共展示了commands.MissingRequiredArgument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_command_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def on_command_error(self, ctx, exception):
        self.stats.increment("RPGBot.errors", tags=["RPGBot:errors"], host="scw-8112e8")
        logging.info(f"Exception in {ctx.command} {ctx.guild}:{ctx.channel} {exception}")
        exception = getattr(exception, "original", exception)
        traceback.print_tb(exception.__traceback__)
        print(exception)
        try:
            if isinstance(exception, commands.MissingRequiredArgument):
                await ctx.send(f"```{exception}```")
            elif isinstance(exception, TimeoutError):
                await ctx.send(await _(ctx, "This operation ran out of time! Please try again"))
            elif isinstance(exception, discord.Forbidden):
                await ctx.send(await _(ctx, "Error: This command requires the bot to have permission to send links."))
            else:
                await ctx.send(f"`{exception} If this is unexpected, please report this to the bot creator`")
        except discord.Forbidden:
            pass 
开发者ID:henry232323,项目名称:RPGBot,代码行数:19,代码来源:RPGBot.py

示例2: on_command_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def on_command_error(ctx, error):

    send_help = (commands.MissingRequiredArgument, commands.BadArgument, commands.TooManyArguments, commands.UserInputError)

    if isinstance(error, commands.CommandNotFound):  # fails silently
        pass

    elif isinstance(error, send_help):
        _help = await send_cmd_help(ctx)
        await ctx.send(embed=_help)

    elif isinstance(error, commands.CommandOnCooldown):
        await ctx.send(f'This command is on cooldown. Please wait {error.retry_after:.2f}s')

    elif isinstance(error, commands.MissingPermissions):
        await ctx.send('You do not have the permissions to use this command.')
    # If any other error occurs, prints to console.
    else:
        print(''.join(traceback.format_exception(type(error), error, error.__traceback__))) 
开发者ID:cree-py,项目名称:RemixBot,代码行数:21,代码来源:bot.py

示例3: on_command_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def on_command_error(self, ctx, exception):
        exc_class = exception.__class__
        if exc_class in (commands.CommandNotFound, commands.NotOwner):
            return

        exc_table = {
            commands.MissingRequiredArgument: f"{WARNING} The required arguments are missing for this command!",
            commands.NoPrivateMessage: f"{WARNING} This command cannot be used in PM's!",
            commands.BadArgument: f"{WARNING} A bad argument was passed, please check if your arguments are correct!",
            IllegalAction: f"{WARNING} A node error has occurred: `{getattr(exception, 'msg', None)}`",
            CustomCheckFailure: getattr(exception, "msg", None) or "None"
        }

        if exc_class in exc_table.keys():
            await ctx.send(exc_table[exc_class])
        else:
            await super().on_command_error(ctx, exception) 
开发者ID:initzx,项目名称:rewrite,代码行数:19,代码来源:bot.py

示例4: setclass_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def setclass_error(self, ctx, error):
        if isinstance(error, commands.MissingRequiredArgument):
            manager = MessageManager(ctx)
            await manager.send_message("Oops! You didn't include your Destiny 2 class.")
            await manager.clean_messages() 
开发者ID:jgayfer,项目名称:spirit,代码行数:7,代码来源:roster.py

示例5: settimezone_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def settimezone_error(self, ctx, error):
        if isinstance(error, commands.MissingRequiredArgument):
            manager = MessageManager(ctx)
            await manager.send_message("Oops! You didn't include your timezone.")
            await manager.clean_messages() 
开发者ID:jgayfer,项目名称:spirit,代码行数:7,代码来源:roster.py

示例6: setprefix_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def setprefix_error(self, ctx, error):
        if isinstance(error, commands.MissingRequiredArgument):
            manager = MessageManager(ctx)
            await manager.send_message("Oops! You didn't provide a new prefix.")
            await manager.clean_messages() 
开发者ID:jgayfer,项目名称:spirit,代码行数:7,代码来源:settings.py

示例7: seteventrole_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def seteventrole_error(self, ctx, error):
        if isinstance(error, commands.MissingRequiredArgument):
            manager = MessageManager(ctx)
            event_role = get_event_role(ctx)

            if not event_role:
                role_display = 'None (anyone can make events)'
            else:
                role_display = format_role_name(event_role)

            await manager.send_message("The current event role is: **{}**\n\n".format(role_display)
                            + "To change the event role, use '{}settings seteventrole <role_name>'".format(ctx.prefix))
            await manager.clean_messages() 
开发者ID:jgayfer,项目名称:spirit,代码行数:15,代码来源:settings.py

示例8: seteventdeleterole_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def seteventdeleterole_error(self, ctx, error):
        if isinstance(error, commands.MissingRequiredArgument):
            manager = MessageManager(ctx)
            event_role = get_event_delete_role(ctx)

            if not event_role:
                role_display = '**None** (only Manage Sever members can delete events)'
            else:
                role_display = format_role_name(event_role)

            await manager.send_message("The current event delete role is: {}\n\n".format(role_display)
                            + "To change the event delete role, use '{}settings seteventdeleterole <role_name>'".format(ctx.prefix))
            await manager.clean_messages() 
开发者ID:jgayfer,项目名称:spirit,代码行数:15,代码来源:settings.py

示例9: feedback_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def feedback_error(self, ctx, error):
        if isinstance(error, commands.MissingRequiredArgument):
            manager = MessageManager(ctx)
            await manager.send_message("You forgot to include your feedback!")
            await manager.clean_messages() 
开发者ID:jgayfer,项目名称:spirit,代码行数:7,代码来源:general.py

示例10: item_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def item_error(self, ctx, error):
        if isinstance(error, commands.MissingRequiredArgument):
            manager = MessageManager(ctx)
            await manager.send_message("Oops! You didn't specify a search term.")
            await manager.clean_messages() 
开发者ID:jgayfer,项目名称:spirit,代码行数:7,代码来源:item.py

示例11: on_command_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def on_command_error(self, ctx, error):
        if self.check_test_environment(ctx):
            if isinstance(error, commands.MissingRequiredArgument):
                logger.error('[ManageCog on_command_error()] Missing argument: {0}'.format(error.param))
                e_obj = await imported_embed(
                    ctx,
                    author=self.config.get_config_value('bot_profile', 'BOT_NAME'),
                    avatar=self.config.get_config_value('bot_profile', 'BOT_AVATAR'),
                    description="Missing argument: {}".format(error.param)
                )
                if e_obj is not False:
                    await ctx.send(embed=e_obj)
            else:
                # only prints out an error to the log if the string that was entered doesnt contain just "."
                pattern = r'[^\.]'
                if re.search(pattern, str(error)[9:-14]):
                    # author = ctx.author.nick or ctx.author.name
                    # await ctx.send('Error:\n```Sorry '+author+', seems like the command
                    # \"'+str(error)[9:-14]+'\"" doesn\'t exist :(```')
                    if type(error) is discord.ext.commands.errors.CheckFailure:
                        logger.warning(
                            "[ManageCog on_command_error()] user {} "
                            "probably tried to access a command they arent supposed to".format(ctx.author)
                        )
                    else:
                        traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
                        return

    # this command is used by the TEST guild to create the channel from which this TEST container will process
    # commands 
开发者ID:CSSS,项目名称:wall_e,代码行数:32,代码来源:manage_cog.py

示例12: on_command_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def on_command_error(ctx, error):
    error_to_skip = [CommandNotFound, MissingRequiredArgument]

    for error_type in error_to_skip:
        if isinstance(error, error_type):
            return

    raise error

# Starting the bot. 
开发者ID:DarkStar7471,项目名称:THM-Bot,代码行数:12,代码来源:main.py

示例13: on_command_error

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        return
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send("Missing a required argument.  Do >help")
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("You do not have the appropriate permissions to run this command.")
    if isinstance(error, commands.BotMissingPermissions):
        await ctx.send("I don't have sufficient permissions!")
    else:
        print("error not caught")
        print(error) 
开发者ID:NullPxl,项目名称:NullCTF,代码行数:14,代码来源:nullctf.py

示例14: logs

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def logs(self, ctx, *, user: User = None):
        """
        Get previous Modmail thread logs of a member.

        Leave `user` blank when this command is used within a
        thread channel to show logs for the current recipient.
        `user` may be a user ID, mention, or name.
        """

        await ctx.trigger_typing()

        if not user:
            thread = ctx.thread
            if not thread:
                raise commands.MissingRequiredArgument(SimpleNamespace(name="member"))
            user = thread.recipient

        default_avatar = "https://cdn.discordapp.com/embed/avatars/0.png"
        icon_url = getattr(user, "avatar_url", default_avatar)

        logs = await self.bot.api.get_user_logs(user.id)

        if not any(not log["open"] for log in logs):
            embed = discord.Embed(
                color=self.bot.error_color,
                description="This user does not have any previous logs.",
            )
            return await ctx.send(embed=embed)

        logs = reversed([log for log in logs if not log["open"]])

        embeds = self.format_log_embeds(logs, avatar_url=icon_url)

        session = EmbedPaginatorSession(ctx, *embeds)
        await session.run() 
开发者ID:kyb3r,项目名称:modmail,代码行数:37,代码来源:modmail.py

示例15: status

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import MissingRequiredArgument [as 别名]
def status(self, ctx, *, status_type: str.lower):
        """
        Set a status for the bot.

        Possible status types:
            - `online`
            - `idle`
            - `dnd` or `do not disturb`
            - `invisible` or `offline`

        To remove the current status:
        - `{prefix}status clear`
        """
        if status_type == "clear":
            self.bot.config.remove("status")
            await self.bot.config.update()
            await self.set_presence()
            embed = discord.Embed(title="Status Removed", color=self.bot.main_color)
            return await ctx.send(embed=embed)

        status_type = status_type.replace(" ", "_")
        try:
            status = Status[status_type]
        except KeyError:
            raise commands.MissingRequiredArgument(SimpleNamespace(name="status"))

        _, status = await self.set_presence(status=status)

        self.bot.config["status"] = status.value
        await self.bot.config.update()

        msg = f"Status set to: {status.value}."
        embed = discord.Embed(title="Status Changed", description=msg, color=self.bot.main_color)
        return await ctx.send(embed=embed) 
开发者ID:kyb3r,项目名称:modmail,代码行数:36,代码来源:utility.py


注:本文中的discord.ext.commands.MissingRequiredArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。