Skip to content

payload.cached_message is None even though message is cached and on_message_edit() fires #3037

@BrainlessDip

Description

@BrainlessDip

Summary

In Pycord 2.7, payload.cached_message is None even when the message is cached, proven by the fact that on_message_edit() fires — this does not happen in 2.6.1.

Reproduction Steps

  1. Send a message
  2. Start the bot
  3. Edit the message twice

Observed Behavior (2.7)

First edit

  • on_raw_message_edit() fires
  • payload.cached_message is None
  • on_message_edit() does not fire
    ✔ expected

Second edit

  • on_raw_message_edit() fires
  • on_message_edit() fires
  • payload.cached_message is still None

⚠️ The message is clearly cached (since on_message_edit() fired), but payload.cached_message incorrectly reports None.


Newly Sent Messages (bot already running)

  1. Send a new message
  2. Edit it

Result in 2.7:

  • on_message_edit() fires
  • payload.cached_message is None

So,

  • Message is cached
  • Raw payload says it is not

Same Steps in 2.6.1 (correct behavior)

  • If on_message_edit() fires:

    • payload.cached_message is populated
  • No contradictions between raw and non-raw events

Minimal Reproducible Code

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(
    command_prefix="!",
    intents=intents,
)


@bot.event
async def on_ready():
    print(f"Logged in as {bot.user} (ID: {bot.user.id})")


# Fires ONLY if message is cached
@bot.event
async def on_message_edit(before, after):
    print("=== CACHED MESSAGE EDIT ===")
    print(f"Message ID: {after.id}")
    print()


# Fires ALWAYS (cached or not)
@bot.event
async def on_raw_message_edit(payload: discord.RawMessageUpdateEvent):
    print("=== RAW MESSAGE EDIT ===")
    print(f"Message ID : {payload.message_id}")
    print(f"Cached?    : {payload.cached_message is not None}")
    print()


bot.run("TOKEN")

Expected Results

on_message_edit() fires  <=>  payload.cached_message is not None

✔ true in 2.6.1
❌ false in 2.7

Actual Results

on_message_edit() fires, but payload.cached_message is None in on_raw_message_edit()

Intents

intents.message_content = True

System Information

- Python v3.13.5-final
- py-cord v2.7.None-final
- aiohttp v3.13.2
- system info: Windows 11 10.0.22631

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions