本质上,我希望机器人浏览频道的消息历史记录,找到包含某些特定文本的消息,然后在同一频道中给出该消息的链接。
通过文档,我想我会使用,async for message in channel.history(params)但我无法弄清楚我的特定用例如何。
我希望我的机器人在调用时将文件(不一定是图像,可以是文本文件)发送到通道。这是我的代码片段:
@bot.command(pass_context=True)
async def send(ctx):
area=ctx.message.channel
await bot.send_file(area, r"c:\location\of\the_file_to\send.png",content="Message test")
Run Code Online (Sandbox Code Playgroud)
但是,它给了我一个错误:
AttributeError: 'Bot' object has no attribute 'send_file'
我尝试按照另一个答案的建议替换send_file为send,但这也不起作用。这里正确的语法应该是什么?