【问题标题】:Trying to make a Discord bot respond after a command试图让 Discord 机器人在命令后做出响应
【发布时间】:2021-07-06 18:29:47
【问题描述】:

我想创建这个,所以每当你使用.choose 和之后的类时,无论是小偷、雇佣兵、黑客还是工程师都可以更改用户的类,但无论何时我尝试它都不起作用。它总是以重新发送.choose 命令结束,如下所示。如何编辑它,而不是重新发送 .choose 命令,它实际上会更改用户类并回复 " 你选择了selected rank 类。"

@client.command(aliases = ['Classes'])
async def classes(ctx):
  SelectEmbed = discord.Embed(
    Title = "Class list!",
    colour = discord.Colour.dark_grey()
)
  SelectEmbed.add_field(name = "Available Classes", value = "Mercenary, Hacker, Engineer and Thief.", inline = True)
  await ctx.send(embed=SelectEmbed)

@client.command(aliases = ['Choose','ChoOse'])
async def choose(ctx):
  SelectClass = discord.Embed(
    TItle = "Choose your class!",
    colour = discord.Colour.dark_grey()
  )
  SelectClass.add_field(name = "Select your class below.",value = "Choose a class: use the '.classes' command to view the class list.", inline = True)
  await ctx.send(embed = SelectClass)

【问题讨论】:

  • 你必须将class设置为必需的参数。

标签: python discord discord.py bots


【解决方案1】:

也许这对你有帮助

@client.command(aliases = ['Classes'])
async def classes(ctx):
  SelectEmbed = discord.Embed(
    Title = "Class list!",
    colour = discord.Colour.dark_grey()
  )
  SelectEmbed.add_field(name = "Available Classes", value = "Mercenary, Hacker, Engineer and Thief.", inline = True)
  await ctx.send(embed=SelectEmbed)

@client.command(aliases = ['Choose','ChoOse'])
async def choose(ctx, name):
  SelectClass = discord.Embed(
    TItle = "Choose your class!",
    colour = discord.Colour.dark_grey()
  )
  SelectClass.add_field(name = "Select your class below.",value = "Choose a class: use the '.classes' command to view the class list.", inline = True)
  await ctx.send(embed = SelectClass)
  await ctx.send(f"You have selected {str(name)}!")

【讨论】:

    猜你喜欢
    • 2021-04-30
    • 2021-03-11
    • 2021-07-22
    • 2021-09-04
    • 2021-03-17
    • 2022-10-24
    • 2021-04-09
    • 2022-12-15
    相关资源
    最近更新 更多