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

Weird Behaviour of member.status and member.activities #891

Closed
3 tasks done
TheKaushikGoswami opened this issue Jan 30, 2022 · 6 comments · Fixed by #1365
Closed
3 tasks done

Weird Behaviour of member.status and member.activities #891

TheKaushikGoswami opened this issue Jan 30, 2022 · 6 comments · Fixed by #1365
Labels
unconfirmed bug A bug report that needs triaging
Milestone

Comments

@TheKaushikGoswami
Copy link

TheKaushikGoswami commented Jan 30, 2022

Summary

Both member.status and member.activities return some weird values.

Reproduction Steps

  • Make a command to fetch a member's status and activities.
  • Add an optional parameter to select the member.
  • Change the default value of member to ctx.author.
  • Have a "Playing a Game" activity and keep your status Online (you can have different activity/status too but the code snippet below is for these status and activity right now, You would need to edit the snippet to reproduce for your case).
  • Run the command 2 times:
    • 1st Time: Pass the member parameter by selecting yourself as the member.
    • 2nd Time: Don't Pass the member parameter (let it use the default value).

Minimal Reproducible Code

import discord
from discord.ext import commands
from discord.commands import slash_command, Option

intents = discord.Intents.all()
bot = commands.Bot(command_prefix="-", case_insensitive=True, intents=intents)

class UserInfo(commands.Cog, name="Cog Name"):

    @slash_command()
    async def userinfo(self, ctx, member: Option(discord.Member, "Choose The Member", required=False)):
        await ctx.defer()
        if member == None:
            member = ctx.author
        status = " "
        activity = "None"
        if member.status == discord.Status.online:
            status = f'🟢'
        elif member.status == discord.Status.offline:
            status = f'🟤'
        if member.activity == None:
            activity = "No Activity"
        else:
            if member.activities[-1].type == discord.ActivityType.custom:
                activity = "None"
            elif member.activities[-1].type == discord.ActivityType.playing:
                activity = f"Playing {member.activities[-1].name}"
        await ctx.followup.send(f"**Status:** {status}\n**Activity:** {activity}")       

bot.add_cog(UserInfo(bot))
bot.run("token-here")

Expected Results

The result in second case should be the same as in first case.

Actual Results

The results produced are different and the second result is weird and incorrect.

Intents

All

System Information

  • Python v3.10.2-final
  • py-cord v2.0.0-beta
    • py-cord pkg_resources: v2.0.0b1
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.22000

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.
@TheKaushikGoswami TheKaushikGoswami added the unconfirmed bug A bug report that needs triaging label Jan 30, 2022
@Bimi05
Copy link
Contributor

Bimi05 commented Jan 30, 2022

Unsure if this is an actual bug but, supposing its output is different each time are you sure that your code does the proper necessary checks? Looking at the docs there's a handful of ways that you can change it to get a member's status and I believe that might be the case.

By that, I mean that you could possibly check the discord.Status enumerator, as it you could perform checks based on its values. Again, it might be a library issue but it may be a code issue and since you have all intents, have a go at altering the code, see if it helps.

@Dorukyum
Copy link
Member

What do you mean by "weird"?

@TheKaushikGoswami
Copy link
Author

What do you mean by "weird"?

I mean, it is not returning the value it should. After all both the values are for same user but still different outputs?

@Dorukyum
Copy link
Member

Dorukyum commented Feb 1, 2022

Can say that when my status was online choosing myself as the member option returned my status as online however ctx.author returned it as offline.

@cmarley3-14
Copy link

cmarley3-14 commented Feb 1, 2022

#898 - I also want to link this here in case it's a related issue. Getting the activities of myself returns a tuple with the CustomActivity (i.e. my custom status) missing, and a Game object instead of an Activity with type: playing.

Similarly, getting the activity of my main bot using a helper bot will return a Game object instead of an Activity. Further, getting the statuses and activities of other users works without issue to the extent I've been testing.

Additional info: Initializing the helper bot with activity = discord.Activity(name="test", type=discord.ActivityType.listening) will have the main bot read the activity as (<Activity type=<ActivityType.listening: 2> name='test' url=None details=None application_id=None session_id=None emoji=None>,), but initializing with type = discord.ActivityType.playing will result in (<Game name='test'>,).

Here's an instance of both custom status and Game (not Activity): (<CustomActivity name='The cubic urge to greeble' emoji=<PartialEmoji animated=False name='🧊' id=None>>, <Game name='Crusader Kings III'>) that I've seen now. But I still can't get my custom status.

@Lulalaby Lulalaby added this to the v2.1 milestone Feb 5, 2022
@jab416171
Copy link
Contributor

This should work as a workaround: member = ctx.guild.get_member(member.id)

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.

6 participants