真的不是骗子吗?说明:This question is not looking to (at)mention a userThis question lists member.mention but does not provide a complete example
我的问题使用Discord.py(如果标题不清楚),我试图弄清楚如何在他们运行命令时向Discord用户添加@ mention属性。
示例:用户输入:$ 99Bot输出:@ User您的报价是:Bingpot!
更新:10/24/2019-@ epic-programmer指出了一个非常严重的复制粘贴错误,我已修复它:)-该修补程序将“成员”设置为命令的参数。我想要得到的是成员的显示名称,并在命令输出中使用它(作为@mention)
@commands.command()
async def mention_ping(self, ctx, member : discord.Member):
await ctx.send(f"PONG {member}")
import random
import discord
from discord.ext import commands
#----
tokenfile = 'token.txt'
with open(tokenfile) as tf:
line = tf.readline()
TOKEN = line.rstrip()
#----
bot = commands.Bot(command_prefix='$')
@bot.command(name='99', help='Responds with a random quote from Brooklyn 99')
async def nine_nine(ctx, member : discord.Member):
brooklyn_99_quotes = [
'I\'m the human form of the 💯 emoji.',
'Bingpot!',
(
'Cool. Cool cool cool cool cool cool cool, '
'no doubt no doubt no doubt no doubt.'
),
]
response = random.choice(brooklyn_99_quotes)
await ctx.send("{} your quote is: {}".format(member, response))
bot.run( TOKEN)
member
参数在错误的位置。尝试将其移至def
语句。
@bot.command(name='99', help='Responds with a random quote from Brooklyn 99')
async def nine_nine(ctx, member : discord.Member):
brooklyn_99_quotes = [
'I\'m the human form of the 💯 emoji.',
'Bingpot!',
(
'Cool. Cool cool cool cool cool cool cool, '
'no doubt no doubt no doubt no doubt.'
),
]
response = random.choice(brooklyn_99_quotes)
await ctx.send("{} your quote is: {}".format(member, response))
bot.run( TOKEN)