【问题标题】:How to mention a user without putting id after command in server如何在服务器中的命令后不添加 id 的情况下提及用户
【发布时间】:2021-08-22 01:51:47
【问题描述】:
@client.command()
async def status(current, content: str):
    status = None
    for member in current.guild.members:
        if str(member.id) == content:
            status = member.status
            break
    if status == discord.Status.online:
        online_embed = discord.Embed(
            title="awa is online", description="", color=0xF6E5E5
        )
        await current.send(embed=online_embed)

我每次都必须做#status [user id],有没有办法只做#status?

【问题讨论】:

  • 你现在是第三次问这个问题了,为什么不等到你得到其他问题的帮助?

标签: discord.py


【解决方案1】:

在命令中获取成员对象(允许您使用用户的 id、他们的姓名等)的最简单方法之一是使用他们提供的转换器。

@client.command()
async def test(current, member: discord.Member=None):
    if member == None: # if no member is provided..
        member = current.author # ..make member the author
    await current.send(f"Hello {member.mention}!")

类似的其他问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-15
    • 1970-01-01
    • 2021-09-21
    • 2011-09-19
    • 2014-12-23
    • 1970-01-01
    • 2017-06-20
    相关资源
    最近更新 更多