Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disnake.Member.status and disnake.Member.raw_status not working well. #108

Closed
3 tasks done
Victorsitou opened this issue Nov 5, 2021 · 2 comments · Fixed by #182
Closed
3 tasks done

disnake.Member.status and disnake.Member.raw_status not working well. #108

Victorsitou opened this issue Nov 5, 2021 · 2 comments · Fixed by #182
Labels
bug Something isn't working p: medium Medium priority s: planned Issue is planned in the future

Comments

@Victorsitou
Copy link
Member

Victorsitou commented Nov 5, 2021

Summary

While trying to get user's status it returns offline in Slash Commands, even though the user isn't offline.

Reproduction Steps

When trying to get user's status in a @bot.command() command it works well and it returns the correctly status, but when using it in a @bot.slash_command, it returns offline. (I don't know if it works well in context menus)

Also, it just works when you have both Members and Presences intents.

Minimal Reproducible Code

Prefix commands that I'm using:

@bot.command()
async def status(ctx):
    # This one works well
    await ctx.send(ctx.author.status)

Slash commands that I'm using:

@bot.slash_command(name="status")
async def status(
    inter: disnake.ApplicationCommandInteraction,
    user: disnake.Member = commands.Param(description="user"),
):
    # This one returrns offline
    await inter.response.send_message(f"Your status is {user.status}")

Extra comment: Using `disnake.ApplicationCommandInteraction.author.status` returns also offline.

Expected Results

Get the user's status.

Actual Results

Returning offline in Slash Commands.

Intents

Presences and Members

Important comment:
It seems that using this way to use intents doesn't work (I may be wrong but at least for the code listed above didn't work)

intents = disnake.Intents()
intents.members = True
intents.presences = True

The way I used to use intents is this one:

intents = disnake.Intents.default()
intents.members = True
intents.presences = True

System Information

  • Python v3.10.0-final
  • disnake v2.2.1-beta
    • disnake pkg_resources: v2.2.1
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19042

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

@Victorsitou Victorsitou added the unconfirmed bug Something might not be working label Nov 5, 2021
@shiftinv
Copy link
Member

shiftinv commented Nov 5, 2021

Thanks!

ApplicationCommandInteraction.author.status always returning offline is a bug, happens due to the fact that the user/member isn't taken from cache and therefore doesn't have presence data:

# TODO: there's a potential data loss here
if self.guild_id:
guild = self.guild or Object(id=self.guild_id)
try:
member = data["member"] # type: ignore
except KeyError:
pass
else:
self.author = Member(state=self._state, guild=guild, data=member) # type: ignore

Similar issue for member parameters, as well as UserCommandInteraction.target, as they aren't taken from the cache either but created solely from the received data:

self.members[user_id] = Member(
data={**member, "user": user}, # type: ignore
guild=guild, # type: ignore
state=state,
)

A workaround in all cases is to call get_member to get the member from cache manually, but that should probably be fixed.

@shiftinv shiftinv added bug Something isn't working and removed unconfirmed bug Something might not be working labels Nov 5, 2021
@Victorsitou
Copy link
Member Author

A workaround in all cases is to call get_member to get the member from cache manually, but that should probably be fixed.

Oh I see, thank you so much for your response!

@shiftinv shiftinv added p: medium Medium priority s: planned Issue is planned in the future labels Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p: medium Medium priority s: planned Issue is planned in the future
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants