【问题标题】:I need to assign a variable via the following user message, how can I do this?我需要通过以下用户消息分配一个变量,我该怎么做?
【发布时间】:2021-02-24 18:36:47
【问题描述】:

我正在 discord py 上编写一个机器人。我需要通过以下用户消息分配变量,我该怎么做?

                    frole = # here I need to set a variable via the following message .family role MaosFamily
                    post = {
                        "_id": self.familydb.count_documents({}) + 1,
                        "role": frole,
                        "voice": None,
                        "boss": ctx.author.id,
                        "zam": None
                    }
                    self.shopdb.insert_one(post)  

【问题讨论】:

    标签: python bots discord.py


    【解决方案1】:

    使用client.wait_for()

    例子:

    frole = await client.wait_for('message', check=lambda m: m.author==ctx.author and m.channel == ctx.channel)
    

    【讨论】:

    • 使用frole.content访问邮件内容
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-26
    • 1970-01-01
    • 1970-01-01
    • 2022-08-24
    • 1970-01-01
    • 2022-08-12
    相关资源
    最近更新 更多