首页 > 解决方案 > 你怎么提

问题描述

我需要用 id 提及一个特定的角色631147065925173310。我什么都试过了,很多人跟我说我不懂python,这很难,但是我学习如何使用discord.py才2天。

if channel.name == "General":
    await ctx.send(f"{ctx.author.mention}needs help at{channel.mention})
else:
    await ctx.send(f"{ctx.author}needs help at an unknown place")

每当一个人写“h!”时,我都想要那个。或帮助,它会说:

@user needs help at #channel @specific role

标签: pythondiscorddiscord.py

解决方案


要提及角色或用户,您应该在消息中使用以下语法:

<@id>

因此,将“id”更改为相应角色的 id,这样您的代码将是:

awit ctx.send(f"<@{userId}>nedds help at<@{channelId}>)

推荐阅读