擅长:python、mysql、java
<p>首先,为了避免与命名混淆,<a href="https://discordpy.readthedocs.io/en/stable/api.html?highlight=on_message#discord.on_message" rel="nofollow noreferrer">^{<cd1>}</a>的参数是一个<a href="https://discordpy.readthedocs.io/en/stable/api.html#discord.Message" rel="nofollow noreferrer">^{<cd2>}</a>对象,通常称为<code>message</code>,而不是<code>ctx</code></p>
<p>有一些与<code>Message</code>对象相关的属性。<code>message.content</code>的值是消息的字符串内容,<code>message.id</code>是消息id,<code>message.reactions</code>是<a href="https://discordpy.readthedocs.io/en/stable/api.html#reaction" rel="nofollow noreferrer">^{<cd9>}</a>对象的列表</p>
<p>如果需要按照用户消息中提供的ID查找消息,则需要执行以下操作</p>
<pre><code>message_id = int(message.content)
</code></pre>
<p>这是到目前为止常用的Python,然后使用该ID查找消息,可能通过调用相关通道上的<a href="https://discordpy.readthedocs.io/en/rewrite/api.html#discord.TextChannel.fetch_message" rel="nofollow noreferrer">^{<cd10>}</a>。如果来自用户的消息与您要访问的消息位于同一频道,则可以执行以下操作:</p>
<pre><code>target_message = await message.channel.fetch_message(message_id)
</code></pre>
<p>然后,您有一个<code>Message</code>对象,如上所述</p>