-
Iām currently working on EterNomm as a founder.
-
Iām currently learning Python, HTML, CSS, Js.
-
First time learning Python August 1, 2021.
-
Ask me about Python.
-
Fun fact I am a Python packages creator, such as Whitehat, Arithmos Cipher.
An Python wrapper for Discord RPC
Home Page: https://pypi.org/project/discord-rpc
License: MIT License
Iām currently working on EterNomm as a founder.
Iām currently learning Python, HTML, CSS, Js.
First time learning Python August 1, 2021.
Ask me about Python.
Fun fact I am a Python packages creator, such as Whitehat, Arithmos Cipher.
I'm getting this error when trying to use your package after being compiled into an exe by pyinstaller.
Here is my code
rpc = DiscordRPC.RPC.Set_ID('Example')
button = DiscordRPC.button(button_one_label='Server Invite', button_one_url="https://discord.gg/batch", button_two_label='Website', button_two_url='https://sped.lol')
rpc.set_activity(state='test', details='test', large_image='WORKING_LARGE_IMAGE_KEY', large_text='test', buttons=button, timestamp=rpc.timestamp())
rpc.run()
It works perfectly fine as just a py file but when compiled it breaks
Copy of #4 since @LyQuid12 won't reopen it.
Sometimes when RPC.set_activity is called, the script crashes with error
if output['evt'] == "ERROR":
KeyError: 'evt'
Adding debug print for RPC.output, the error is
{'code': 1003, 'message': 'data size does not match what was received'}
Seems to happen regardless of what the activity is set to.
Hey.
I have setup everything, even created the app, but I can't see the status update in discord.
Here is the debug log:
2024-03-28 20:28:43 :: [DEBUG @ presence.py._setup:137] :: Connected to \\?\pipe\discord-ipc-0
2024-03-28 20:28:43 :: [DEBUG @ presence.py._send:164] :: {'v': 1, 'client_id': ''}
2024-03-28 20:28:43 :: [DEBUG @ presence.py._recv:156] :: {'cmd': 'DISPATCH', 'data': {'v': 1, 'config': {'cdn_host': 'cdn.discordapp.com', 'api_endpoint': '//discord.com/api', 'environment': 'production'}, 'user': {'id': '', 'username': '', 'discriminator': '0', 'global_name': '', 'avatar': None, 'avatar_decoration_data': None, 'bot': False, 'flags': 32, 'premium_type': 0}}, 'evt': 'READY', 'nonce': None}
2024-03-28 20:28:43 :: [INFO @ presence.py.handshake:181] :: Connected to account ()
{'cmd': 'SET_ACTIVITY', 'args': {'pid': 19396, 'activity': {'state': 'Test', 'details': 'Test'}}, 'nonce': '221c576b-ba14-4fc9-a5d1-d7381d02e8df'}
2024-03-28 20:28:43 :: [DEBUG @ presence.py._send:164] :: {'cmd': 'SET_ACTIVITY', 'args': {'pid': 19396, 'activity': {'state': 'Test', 'details': 'Test'}}, 'nonce': '221c576b-ba14-4fc9-a5d1-d7381d02e8df'}
2024-03-28 20:28:43 :: [INFO @ presence.py.set_activity:100] :: RPC set
Do you know what might b going wrong?
For some discord applications like spotify and in general media consumption discord has the abilty to display "is listening/watching" with a progress bar and albums/cover art. I can't seem to find a way to recreate this by using this library or the javascript one.
when i click on the button it doesnt open the link.
I have been facing this issue intermittently and the only common factor I have managed to find is that it happens when Discord is closed (ie, in the system tray) for a long time.
I managed to isolate the problem to this line https://github.com/Senophyx/Discord-RPC/blob/main/discordrpc/presence.py#L160
enc_header += self.socket.read(header_size)
It seems like when Discord is closed for a long time, the socket enters hibernation and doesn't respond to the request and because of that, the program effectively hangs, waiting for a response.
It can be fixed by opening Discord (from the system tray) but that seems very un-intuitive for end user.
Is there a way to trigger a TimeOut event or something to check if the connection is live?
Sometimes when RPC.set_activity
is called, the script crashes with error
if output['evt'] == "ERROR":
KeyError: 'evt'
Adding debug print for RPC.output, the error is
{'code': 1003, 'message': 'data size does not match what was received'}
Seems to happen regardless of what the activity is set to.
https://github.com/LyQuid12/Discord-RPC/blob/main/examples/rpc-with-button.py#L3
What is RPC and how it works?
I have a bot written in python, but I'm not sure how to setup.
The only thing I care about is custom buttons when opening bot's profile on Discord.
Does activity have to be set to gaming?
or other activities also can show the buttons or images?
Is Discord-RPC like a second bot that other bots contact to receive information such as buttons and images?
app_id seems like to mean client_id of a bot.
Sorry, I'm really confused about how it all works.
File "project_path/src/__main__.py", line 15, in main
RPC = discordrpc.RPC.set_id(app_id=CLIENT_ID)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "project_path/.venv/lib/python3.11/site-packages/discordrpc/presence.py", line 33, in set_id
return DiscordUnix(app_id)
^^^^^^^^^^^^^^^^^^^
File "project_path/.venv/lib/python3.11/site-packages/discordrpc/presence.py", line 20, in __init__
self._connect()
File "project_path/.venv/lib/python3.11/site-packages/discordrpc/presence.py", line 218, in _connect
pipe_path = self._get_pipe_path()
^^^^^^^^^^^^^^^^^^^^^
TypeError: DiscordUnix._get_pipe_path() takes 0 positional arguments but 1 was given
Full Trace Error:
File "C:\Users\right\AppData\Local\Programs\Python\Python311\Lib\site-packages\discordrpc\presence.py", line 192, in _connect
self._open = open(path, "w+b")
^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '\\\\?\\pipe\\discord-ipc-0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\right\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
self.run()
File "C:\Users\right\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "c:\Users\right\Desktop\D\tool.py", line 2185, in rpc
rpc = discordrpc.RPC.set_id(appID)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\right\AppData\Local\Programs\Python\Python311\Lib\site-packages\discordrpc\presence.py", line 31, in set_id
return DiscordWindows(app_id)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\right\AppData\Local\Programs\Python\Python311\Lib\site-packages\discordrpc\presence.py", line 20, in __init__
self._connect()
File "C:\Users\right\AppData\Local\Programs\Python\Python311\Lib\site-packages\discordrpc\presence.py", line 194, in _connect
raise Error("Failed to open {!r}: {}".format(path, e))
discordrpc.exceptions.Error: Failed to open '\\\\?\\pipe\\discord-ipc-0': [Errno 2] No such file or directory: '\\\\?\\pipe\\discord-ipc-0'
This just started happening recently.
I'm aware this is only an error you'd see if you aren't on Linux, and as said on another issue, I tried other versions but it still returned the same error. I'm on windows btw
A declarative, efficient, and flexible JavaScript library for building user interfaces.
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ššš
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ā¤ļø Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.