【发布时间】:2021-09-21 19:51:53
【问题描述】:
所以我正在尝试构建一个不和谐的机器人,我想要的功能之一是引用以前的消息并从中提取数据。我已经存储了我想引用的消息 ID,但我似乎找不到如何从它的 ID 中提取消息对象。
if split[0] == 'ref':
if (len(split) < 2):
await message.channel.send("!ref,poll or sg,id number")
if (len(split) == 3):
if split[1] == "poll":
for x in db["poll"]:
if x[1] == message.guild.id and x[0] == split[2]:
original = await discord.utils.get(message.channel, message_id=int(split[2]))
await message.channel.send(original.content)
我一直对原始变量使用错误的语法,但我无法弄清楚
我尝试过使用
original = await message.channel.fetch_message(int(split[2]))
得到了
Bot is online as *******
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 277, in on_message
original = await message.channel.fetch_message(int(split[2]))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1132, in fetch_message
data = await self._state.http.get_message(channel.id, id)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 250, in request
raise NotFound(r, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message
我也有我想从中提取的频道的 ID
【问题讨论】:
标签: python discord discord.py