你怎么说

时间:2019-10-08 15:49:24

标签: python discord discord.py

我需要提及ID为631147065925173310的特定角色。我已经尝试了一切,许多人对我说,我不了解python,这很难,但是我正在学习如何使用discord.py仅两天。

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

2 个答案:

答案 0 :(得分:0)

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

<@ id>

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

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

答案 1 :(得分:0)

您可以尝试

user = self.bot.get_user(ctx.author.id)
role = ctx.guild.get_role(631147065925173310)
await ctx.send(f"{user.mention} needs help in {ctx.channel.mention}, please attend {role.mention}")

如果您在齿轮中使用此代码,请使用我的代码,并且如果您使用bot作为命令。

如果您在主要命令中使用此命令,请使用bot.get_user(ctx.author.id)代替我的命令。

相关问题