I want to set up a python script that runs automatically in some situations which opens different programs and among other things joins my main discord voice channel. I figured out most of it, but with discord I am struggling so far. Every tutorial I found is for dicord bots - that's not what I am looking for. I want my currently logged in user to join a specific channel if that channel is available.
I already tried to just copy the link for that channel and use the webbrowser
module:
import webbrowser
webbrowser.open('https://discord.com/channels/some_channel_id/some_other_id')
But that uses the browser, and I have not found a way for it to open in discord yet.
The tutorials was speaking of earlier all need an api token. I would prefer if I don't need one, to keep the dependencies as small as possible.
I already worked with somewhat similar apis (telegram for example), and I can imagine that there's no way without a token.
But just to be sure, is there a solution?
You can indeed open a link in the discord app with the webbrowser
module in python.
Here's an example code:
import webbrowser
# Discord link to open
discord_link = "https://discord.com/channels/some_channel_id/some_other_id"
# Use the "discord://" protocol handler to open the link in the Discord app
discord_protocol_link = discord_link.replace("https://", "discord://")
webbrowser.open_new(discord_protocol_link)
You (of course) need the discord app on your PC in order for this to work. If you have any questions or problems, feel free to ask me.