【问题标题】:How to get a specific entry from a message | discord.py如何从消息中获取特定条目 |不和谐.py
【发布时间】:2021-07-31 14:46:05
【问题描述】:

我正在创建一个 DC Bot,它将接受即将举行的活动的注册,为此,用户需要以这种格式发送消息:

团队名称:-
玩家 1-
玩家 2-
玩家 3-
玩家 4-

但我想从他们的信息中提取的只是他们输入团队名称的内容。我以前从来没有做过这样的事情,所以如果你能把我推荐给类似的代码或文档,那就太好了!

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    您可以使用commands.Greedy 来获取成员列表。

    像这样调用它get_name @member1 @member2 Long team name

    @bot.command()
    async def get_team(ctx, members: commands.Greedy[discord.Member], *, Teamname: str):
        print(f"Team Leader: {ctx.author}")
        print(members)
        print(Teamname)
        if len(members) != 4:
            return await ctx.send("members must be 4)
    
        # code here
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-28
      • 2021-06-28
      • 2021-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-26
      相关资源
      最近更新 更多