interactions-py / interactions.py

A highly extensible, easy to use, and feature complete bot framework for Discord
https://interactions-py.github.io/interactions.py/
MIT License
839 stars 184 forks source link

fix: correct usage of user id in interaction metadata #1729

Closed retr0-init closed 2 months ago

retr0-init commented 2 months ago

Pull Request Type

Description

When trying to retrieve the user id of the response metadata of a message, it returns user_id is not the valid attribute of the object.

Changes

There is a valid user id attribute in the class already, which is _user_id. I suspect it was just a typo.

Related Issues

N/A

Test Scenarios

@interactions.slash_command(
    "test1", description="test channel command", scopes=[DEV_GUILD] if DEV_GUILD else None
)
@interactions.slash_option(
    name="integer",
    description="int",
    opt_type=interactions.OptionType.STRING,
    required=True
)
async def test_cmd1(self, ctx: interactions.SlashContext, integer: str):
    """Register as an extension command"""
    msg: interactions.Message = await ctx.channel.fetch_message(integer)
    msg_ref: interactions.Message = msg.interaction_metadata
    if msg_ref:
        print(msg_ref)
        await ctx.send(f"replied to {msg_ref.user}")
    else:
        await ctx.send("This message does not have a reference")

Python Compatibility

Checklist