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

member status not working with slash commands #1194

Closed
3 tasks done
jab416171 opened this issue Mar 23, 2022 · 6 comments · Fixed by #1365
Closed
3 tasks done

member status not working with slash commands #1194

jab416171 opened this issue Mar 23, 2022 · 6 comments · Fixed by #1365
Labels
unconfirmed bug A bug report that needs triaging

Comments

@jab416171
Copy link
Contributor

jab416171 commented Mar 23, 2022

Summary

When using slash commands, ctx.author.status is always offline.

Reproduction Steps

Create a slash command that uses ctx.author.status, and it will always be "offline". As a side effect, ctx.author.is_on_mobile() is always false. However, if you pass in a member (even if it's yourself), the status code works as intended.

Minimal Reproducible Code

import discord
from discord.commands import slash_command
from discord.ext import commands

class Example(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.slash_command()
    async def status(self, ctx, member: Option(discord.Member, required=False) = None):
        """Show your status"""
        if not member:
            member = ctx.author
        online = str(member.status)
        if member.is_on_mobile():
            await ctx.respond(f"{member.display_name} is on mobile and is {online}!")
        else:
            await ctx.respond(f"{member.display_name} is not on mobile and is {online}!")

bot = commands.Bot(command_prefix=('s!'), case_insensitive=True, intents=discord.Intents().all(), debug_guilds=[881207955029110855])
bot.add_cog(Example(bot))

bot.run(token)

Expected Results

I expect the status to correctly reflect the user's status

Actual Results

The user is always offline

Intents

all

System Information

  • Python v3.10.2-final
  • py-cord v2.0.0-beta
    • py-cord pkg_resources: v2.0.0b5
  • aiohttp v3.8.1
  • system info: Linux 5.16.12-arch1-1 Update README.rst #1 SMP PREEMPT Wed, 02 Mar 2022 12:22:51 +0000

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

May be related to #891
As a workaround I can do member = ctx.guild.get_member(member.id)

@jab416171 jab416171 added the unconfirmed bug A bug report that needs triaging label Mar 23, 2022
@lorddusk
Copy link

Does your bot have the presence intent enabled on the bot page?

@plun1331
Copy link
Member

Most likely a side effect of Interaction building a Member object using the data Discord sends in the interaction payload, which (iirc) doesn't contain presence data.

@jab416171
Copy link
Contributor Author

@lorddusk yes, hence the workaround working :) or passing in a Member to the function.
@plun1331 huh interesting. what would it take to fetch that presence data?

@lorddusk
Copy link

member = await ctx.guild.fetch_member(member.id)

I suppose?

@jab416171
Copy link
Contributor Author

I mean in the library :) I have that as a workaround

@lorddusk
Copy link

Oh lol, sorry, didn't see that at the bottom, I'll bow out again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug A bug report that needs triaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants