TenType / discord-rich-presence

A lightweight and safe package for creating custom rich presences on Discord.
https://pypi.org/project/discord-rich-presence/
MIT License
8 stars 2 forks source link

Rich Presence missing its image and only existing for 10 seconds #4

Closed TPEcool closed 1 year ago

TPEcool commented 1 year ago

I did everything like in the examples, however the rich presence simply does not work. What am I doing wrong?

discord_APPID = '1132691764755578910'
with Presence(discord_APPID) as rpc:
    rpc.set(
        {
            'state': 'In Game',
            'details': 'beeMMX R',
            'tilestamps': {'start':int(time.time())}
        }
    )

It does neither errors, nor shows up in the Discord app. A while ago I had rich presence problems with a VS Code extension because I was using Discord in the browser, and switching to the app helped. However, I still am using the app, tried restarting it and my rich presence still doesn't work. I also tried adding the while True: time.sleep(15) part, but nothing changed.

TPEcool commented 1 year ago

My program also redirects all errors and logs to a text file, but it is completely empty.

TenType commented 1 year ago

Are you sure you copied the example correctly? Your code segment has a typo (tilestamps -> timestamps).

TPEcool commented 1 year ago

Oh, thanks. Guess i somehow didn't notice it.

TenType commented 1 year ago

This was also partially my fault- the package should have raised an exception if Discord rejected anything. I've uploaded v1.1.0 to improve the error handling and prevent this issue. Thank you for bringing this to my attention!

TPEcool commented 1 year ago

I updated the package to 1.1.0, the presence does not show an image and the program neither crashes nor prints a warning message.

rpc.set(
            {
                'state':'In Game',
                'details':'File: '+('none' if filename is None else '\''+os.path.basename(filename)+'\''),
                'timestamps':{'start':startTime.get()},
                'assets':{
                    'large-image':'beemmx_r',
                    'large_text': 'beeMMX R is a tool which generates music packages for BEE2. Learn more by clicking the GitHub button.'
                },
                'buttons':[
                {
                    'url':'https://github.com/TPEcool/beeMMX-R',
                    'label': 'beeMMX R on GitHub'
                },
                {
                    'url':'https://discord.gg/gb7cp6asJF',
                    'label':'Discord server'
                }
            ]
            }

Additionally, the presence disappears after 10 seconds. The program keeps running, due to tk.mainloop(), but 10 seconds after it's gone.

TPEcool commented 1 year ago

About the image: nevermind. I screwed up an underscore.

TenType commented 1 year ago

Unfortunately, it looks like Discord does not reply with an error if you mistype the asset key, so I can't really do much about that. Please double-check the examples and Discord docs before opening another issue. Thanks :)

TenType commented 1 year ago

Regarding the presence disappearing after 10 seconds, you might want to check that your code is continuously running inside the "with" statement (with Presence(id) as rpc:). The rich presence works fine on my end, so maybe you can double check your loop to see if it is running as expected. Hope this helps.