【发布时间】:2021-12-11 00:01:09
【问题描述】:
我正在用 Python 制作一个 Discord 机器人,我想添加一个功能,当我使用命令 _throw 并 ping 用户时,机器人将根据用户 ping 回复(最好是普通的短信, 不嵌入)。目前,我有这个代码:
if message.content == "_throw":
user = message.mentions[0]
await message.channel.send("You threw a hamster to " + f"{user}" + "!")
但我的机器人根本没有回复它(PyCharm 没有看到任何错误)。
这是我的机器人脚本:
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('_hi'):
await message.channel.send(f'Hello, {message.author.mention}!')
if message.content == "_throw":
user = message.mentions[0]
await message.channel.send("You threw hamster to " + f"{user}" + "!")
if message.content.startswith("_userinfo"):
user = message.mentions[0]
emb14 = discord.Embed(
title=f"@{user} info:",
colour=discord.Colour.dark_blue()
)
emb14.set_image(url=user.avatar_url)
emb14.add_field(name=f"Name", value=f"{user}", inline=True)
emb14.add_field(name=f"Discord Joined date", value=f"{user.created_at}", inline=False)
emb14.add_field(name=f"Server Joined date", value=f"{user.joined_at}", inline=False)
emb14.add_field(name="Profile Picture", value=":arrow_down: :arrow_down: ", inline=False)
await message.channel.send(embed=emb14)
client.run('TOKEN')
有什么想法吗?
【问题讨论】:
标签: python discord discord.py