【问题标题】:DM command that are only available to premium users仅高级用户可用的 DM 命令
【发布时间】:2022-01-18 07:45:47
【问题描述】:

我正在尝试编写一个命令来向提到的用户发送消息。此命令仅适用于高级用户。但是,即使使用此命令的用户是高级用户,我的机器人仍然会说 '哎呀!此命令仅供高级用户使用。'。如何使这个命令起作用?

@client.command(aliases=['dm'])
async def message(ctx, member: discord.Member, description):
  description = description
  em=discord.Embed(title="You received a letter..", description=description, color=0xe9a9a9)
  em.set_author(name=f"{ctx.author.name} ━ Message", icon_url=ctx.author.avatar_url)
  em.set_footer(text="DM a Manager to report harrassment")

  if ctx.author.id == "88877713685543985":
    await member.send(embed=em)
    await ctx.send(f"Your message has been delivered to {member.mention}!", embed=em)
    return

  else:
    await ctx.send("Oops! This command is only available to premium users.")
    return

【问题讨论】:

  • 请不要在标题或问题正文中添加“固定”之类的内容。如果您设法解决了问题,那么要么接受帮助您解决问题的答案,要么在您的解决方案中发布您自己的答案并在超时后接受。

标签: python discord bots


【解决方案1】:

这应该可行 -

if ctx.author.Profile.premium:
    await member.send(embed=em)
    await ctx.send(f"Your message has been delivered to {member.mention}!", embed=em)
    return

else:
    await ctx.send("Oops! This command is only available to premium users.")
    return

【讨论】:

  • 我试过但没用
【解决方案2】:
async def message(ctx, member: discord.Member, description):
  description = description
  em=discord.Embed(title="You received a letter..", description=description, color=0xe9a9a9)
  em.set_author(name=f"{ctx.author.name} ━ Message", icon_url=ctx.author.avatar_url)
  em.set_footer(text="DM a Manager to report harrassment")

  if ctx.author.id == 848737136855466035:
    await member.send(embed=em)
    await ctx.send(f"Your message has been delivered to {member.mention}!", embed=em)
    return

  else:
    await ctx.send("Oops! This command is only available to premium users.")
    return

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-24
    • 2021-09-15
    • 2021-05-17
    • 2013-08-03
    • 2021-04-04
    • 1970-01-01
    • 2020-10-10
    • 2022-11-09
    相关资源
    最近更新 更多