如何使我的discord.py机器人提到我的消息中提到的某人?

问题描述

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

解决方法

(这也是我的第一个答复!)

所以可以说

'tiles': [
'https://tiles.arcgis.com/tiles/QcN4ko50whTktDF1/arcgis/rest/services/Ortho_Midland2020_0520and0521/MapServer/tile/{z}/{x}/{y}.jpg'
],
,

好的,上面的那个几乎是正确的。 解决方案是:

@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,并且异步定义当然是:)