[英]How to get discord bot to mention me and the person i mention in the command
example of what I mean (" +slap @examplename") the bot would then put in chat "@me slapped @examplename" I just can't seem to get it to work. 我的意思示例(“ + slap @examplename”),然后该机器人将聊天“ @me slapped @examplename”,但我似乎无法使其正常工作。
import discord
from discord.ext.commands import Bot
bot = Bot(command_prefix='+')
bot.command()
async def slap(self, member : discord.Member):
"""<member>: Be careful with this one."""
await self.bot.say("*slaps {0} around a bit with a large, girthy trout*".format(member))
@bot.event
async def on_ready():
print ("------------------------------------")
print ("Bot Name: " + bot.user.name)
print ("Bot ID: " + bot.user.id)
print ("Discord Version: " + discord.__version__)
print ("------------------------------------")
await bot.change_presence(game=discord.Game(name='Created By Pluto'))
bot.run('')
I've removed self
, as you don't appear to be using cogs: 我删除了self
,因为您似乎没有使用齿轮:
bot.command(pass_context=True)
async def slap(member: discord.Member):
"""<member>: Be careful with this one."""
await bot.say("{} slaps {}".format(ctx.message.author.mention, member.mention))
Member
objects (including message.author
) have a mention
attribute that allows you to mention them easily. Member
对象(包括message.author
)具有mention
属性,可让您轻松提及它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.