【问题标题】:My AFK command is only showing one word when I write the reason. Why?当我写下原因时,我的 AFK 命令只显示一个字。为什么?
【发布时间】:2021-05-02 20:14:08
【问题描述】:

我的 AFK 命令效果很好,除了我只能使用一个词的原因。例如,我会说 -afk 遛狗。每当有人在我进入 AFK 的不和谐服务器中对我进行 ping 操作时,它只会说 (user) if afk。原因:走路。我试图弄清楚如何让它说出多个单词而不仅仅是一个单词。 这是我的一些 afk 命令

@client.event async def on_message(消息): 全球痛苦者 如果 afkdict 中的 message.author : afkdict.pop(message.author)

for member in message.mentions:  
    if member != message.author:  
        if member in afkdict:  
            afkmsg = afkdict[member]  
            await message.channel.send(f" {member} is afk. Reason: {afkmsg}")
await client.process_commands(message)

【问题讨论】:

    标签: python discord bots


    【解决方案1】:

    遗憾的是我还没有 50 个代表,否则我只会评论 你忘了提供 afk 命令。

    我可以想象你的错误:

    @client.command()
    async def afk(ctx, *, reason):
        global afkdict
        afkdict[ctx.author] = reason
    

    重要的是*,这意味着消息中该点之后的所有内容都被推入参数参数中。

    例如 -afk 遛狗

    --->原因是“遛狗”

    【讨论】:

    • 非常感谢。我很容易犯错,哈哈
    猜你喜欢
    • 2021-07-25
    • 2021-07-15
    • 2018-08-29
    • 2018-07-15
    • 1970-01-01
    • 2021-06-06
    • 2016-04-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多