Python 回复邮件discord.py
我想让我的机器人在用户键入某个句子时对用户的消息做出反应 我要回复的代码:Python 回复邮件discord.py,python,discord,Python,Discord,我想让我的机器人在用户键入某个句子时对用户的消息做出反应 我要回复的代码: await ctx.message.reply("I just replied to you") 我得到一个错误: ctx.message has no attribute "reply" 我可以使用什么代码使bot回复消息 当我说“回复”时,我的意思与用户可以在消息上按“回复”相同,一个选项是使用您可以找到的Cog.listener,但要回答您的问题,我使用Cog.liste
await ctx.message.reply("I just replied to you")
我得到一个错误:
ctx.message has no attribute "reply"
我可以使用什么代码使bot回复消息
当我说“回复”时,我的意思与用户可以在消息上按“回复”相同,一个选项是使用您可以找到的
Cog.listener
,但要回答您的问题,我使用Cog.listener的方式是:
@bot.listen('on_message')
async def stuff(message):
if message.content.startswith("buttlerprefix"): # this tells the bot what to listen for. If a user types `buttlerprefix` in any text channel, it will respond with what's below
msg = await message.channel.send("my prefix is `>`") # set the sending message equal to a variable so that you can manipulate it later like I did with the timer, and delete function below
await asyncio.sleep(10) # tells the bot to wait 10 seconds before continuing below
await msg.delete() # deletes the send message after 10 seconds
如果您有任何进一步的问题,或者遇到任何我在这里看不到的错误,请与我联系:)尝试将该行替换为
await ctx.send('I just replied to you')
Discord.py还不支持新的“回复”功能。不幸的是,除非他们将回复功能添加到库中,否则您无法真正使用回复功能。对于这里的任何新用户,从1.6.0 discord.py rewrite更新开始,您现在可以回复了 每个
discord.abc.Messageable
现在都有一个reply属性。要回答,只需使用
wait ctx.reply('Hello!')
你也不能在回复中用提及作者=False
等待ctx.reply('Hello!',提及作者=False)
您还可以找到一个基本示例不,我知道要发送消息,您可以使用它,但我希望它专门回复消息,比如右键单击消息并按reply时,您使用的discord.py版本是什么?文档上说它是在版本1.6中添加的。我不知道这是否与我使用PyCharm有关,但根据文档,discord.py的最新版本是1.5.1,所以可能它还没有实现。嗨,当我说“回复”时,我指的是回复,就像用户右键单击并按“回复”一样。我真的很抱歉,但我不知道该怎么做:(不过我会遵循这一点,这样如果有人想出了一个方法,那么我也可以学到一些新东西:)我得到一个错误,说
AttributeError:'Context'对象没有属性“reply”
,有人能帮忙吗?@NicholasChen你需要更新到discord.py 1.6Thanks,我会的