Skip to content

member status not working with slash commands #1194

Closed
@jab416171

Description

@jab416171

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions