簡體   English   中英

當他們說出某個命令時,我如何提及成員?

[英]How do i mention a member when they say a certain command?

我試圖讓機器人說“嘿(用戶)這里是 hxd 的下載鏈接”有人可以幫助我嗎?

async def hxd(ctx):
  await client.say('Here is a download link for hxd')

每個discord.Member object 都有一個mention屬性。
以下是你如何使用它:

@client.command()
async def hxd(ctx):
  await client.say(f"Hey {ctx.author.mention}! Here's a download link for hxd")

您可以使用getpass.getuser()

from getpass import getuser
async def hxd(ctx):
  await client.say(f'Hey {getuser()} here is a download link for hxd')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM