interactions.py icon indicating copy to clipboard operation
interactions.py copied to clipboard

[BUG] Guild is not passed to a message when using a Context menu

Open mAxYoLo01 opened this issue 2 years ago • 1 comments

Library Version

latest

Describe the Bug

The guild that a message command is used on is not defined (i.e. ctx.target.guild is None). Most of the time, ctx.guild can be used instead for the user to work with but that means that some of the Message class features do NOT work as intended since the message acts as if it were written in DMs. For example: #1535 returns users even when used in a guild if the message was not previously cached.

Steps to Reproduce

@interactions.context_menu(name="Test", context_type=interactions.CommandType.MESSAGE)
async def test(ctx: interactions.ContextMenuContext):
    print(ctx.target.guild)
    print(ctx.guild)

Results:

> None
> Guild(...)

Expected Results

Expected:

> Guild(...)
> Guild(...)

Minimal Reproducible Code

No response

Traceback

No response

Checklist

  • [X] I have searched the open issues for duplicates.
  • [X] I have shown the entire traceback, if possible.
  • [X] I have removed my token from display, if visible.
  • [X] I have attempted to debug this myself, and I believe this issue is with the library

Additional Information

No response

mAxYoLo01 avatar Aug 19 '23 09:08 mAxYoLo01

I believe this is proper and expected behaviour. ctx.target is a property method for safely retrieving an object of Guild, Member or User through the interaction payload's resolved data – we're using .get() in our call site which can return None if the resolved object cannot be found.

Our current logic handles parsing the existing interaction data, not our cache. Do you mind explaining why you believe the expected result should be a guild?

eightween avatar Dec 09 '23 22:12 eightween