【问题标题】:DiscordPY error, trouble finding command authorDiscordPY 错误,找不到命令作者
【发布时间】:2017-06-28 06:24:41
【问题描述】:

我无法弄清楚如何从 discordpy 中的命令中找到消息的作者,我已经阅读了文档,但根本无法找出问题所在。我尝试了各种方法,但似乎都没有奏效,因此非常感谢您对此提供一些建议,谢谢!收到的问题是“上下文”对象没有属性“较低”,我不明白,因为 .lower() 指的是状态

    @client.command(pass_context=True)
    async def swear(state, ctx):
        global filtertext
        if state.lower() == "off" and (ctx.author.id) in Admins and filtertext != []:
            filtertext=[]
            status = False

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    当你使用命令扩展时,它需要 ctx 作为第一个变量。

    你只需要切换状态和ctx。

    async def swear(ctx, state)
    

    另外请注意,这只包含命令后的第一个单词。 多于 1 个单词,

    async def swear(ctx, *, state)
    

    另外,我建议加入 DiscordAPI 服务器,因为它们可以比 stackexchange 更快地帮助您。

    【讨论】:

    • 非常感谢 :) 您的第二条评论帮助我解决了我遇到的另一个问题 :)
    • 如果对您有帮助,请留下答案并投票!谢谢。
    猜你喜欢
    • 2020-11-21
    • 1970-01-01
    • 2016-03-24
    • 2016-07-12
    • 2016-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多