首页 > 解决方案 > 如何使用 Python 中的机器人在 Discord 中发送某人的姓名

问题描述

我正在编写我的 Python Discord 机器人,在询问时,

Warn <@anyone>

应将 DM 发送到@anyoneDiscord 中。

到现在为止,我写过,

if message.content.startswith('Warn '):

现在我想将整个消息转换为字符串格式,然后从中删除“警告”。@anyone这样我就很容易得名了。但我无法做到这一点。此外,我不知道是否可以转换为字符串。

有人能回答我的问题吗?感谢您阅读我的问题。

标签: pythondiscorddiscord.pymention

解决方案


通过@user来获得使用,这就是我的做法

@client.command() #to start the command
async def warn(ctx, member : discord.member): #name and import ctx / other things too 
       await ctx.send(f"{member.mention}")

如果我做错了,请告诉我它有点


推荐阅读