【问题标题】:Author on Discord.pyDiscord.py 上的作者
【发布时间】:2018-11-15 02:52:32
【问题描述】:

我要制作一个不和谐机器人,当你这样做时 !join 它会在其中将 6 个人放入团队中进行嵌入。我想这样做,所以当它得到 6 时,它会说人不和谐的名字而不是“玩家 1”。我该怎么做?

elif message.content.startswith('!join'):
global lobby
if (lobby == 5):
  lobby -= 6
  embed = discord.Embed(title="**Teams in the 6 Mans**", description="**Team 1** \nPlayer 1\nPlayer 2\nPlayer 3\n\n**Team 2**\nPlayer 4\nPlayer 5\nPlayer 6", color=0x0000FF)
  await client.send_message(message.channel, embed=embed, )

【问题讨论】:

  • 你真的应该看看命令扩展和重写分支

标签: python bots discord discord.py


【解决方案1】:

不鼓励使用全局变量。也就是说,要访问消息作者的不和谐用户名,您想使用message.author.name

【讨论】:

  • 如何在描述中添加它?
  • embed = discord.Embed(title="**Teams in the 6 Mans**", description="**Team 1** \nPlayer 1\nPlayer 2\nPlayer 3\n\n**Team 2**\nPlayer 4\nPlayer 5\n"+messsage.author.name, color=0x0000FF) ?
  • 好的,我将如何使它具有多个名称,并且不仅捕获最后一个执行 !join 的人
  • 您必须将它们存储在一个列表中,并相应地格式化您的标题。我不会用勺子喂你代码,但你应该看看那里的 for 循环 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-29
  • 2019-07-10
  • 2021-04-01
相关资源
最近更新 更多