我怎样才能让我的 discord.py 机器人提到我的消息中提到的人?

How can I make my discord.py bot mentions someone mentioned in my message?

所以我知道有一个关于堆栈溢出的类似问题,但它是针对 discord.js 的,我使用 discord.py 所以有人可以告诉我(这也是我关于堆栈溢出的第一个问题)

(这也是我第一次回复!)

这么说吧

import discord
from discord.ext import commands #or command I can't remember)

#setup setting(on_ready.. etc)

@client.command(ctx, target:discord.Member == None) #CTX represents your command, target means your mentioned member

if target == None:
    await ctx.send("You didn't mention anyone!")
else:
    await ctx.send(target.mention)

#client run token

好的所以上面的几乎是正确的。 解决方案是:

@client.command()
async def something(ctx, target:discord.Member = None):
    if target == None:
        await ctx.send("You didn't mention anyone!")
    
    else:
        await ctx.send(target.mention)
#whatever other code

所以它是 target:discord.Member = None 而不是 target:discord.Member == None,当然还有异步定义 :)