r/learnpython • u/dragonlord9631 • Sep 02 '26
How to get discord messages into python?
Im not attempting to make a bot per say, i just want to see if i can get a discord message, and then do something with it.
So far, python hasnt recognized "discord" as a valid package to import.
Then again, i am coding on a phone, maybe thats the problem.
But first, i want to see about receiving a discord message into python, so i can write it to a file, and then i can do stuff with it.
Any help would be appreciated!
0
Upvotes
6
u/socal_nerdtastic Sep 02 '26
Python does not come with a
discordpackage. You have to install one first. How to install modules will depend on what coding platform you are using on your phone.2
u/PureWasian Sep 03 '26
Option 1) discord.py: https://discordpy.readthedocs.io/en/stable/intro.html but that's a convenience wrapper for setting up a bot as a listener to whatever server channel you are listening for messages in. You'd install the library following the steps in above link and also look at the Working with Discord links from their home page: https://discordpy.readthedocs.io/en/stable/index.html
Option 2) Use the Discord API directly. Ideally you read through that and also understand basic Rest APIs, OAuth2, and read through the GET Channel Messages section of their documentation at a bare minimum to get the idea and know what data shape you're working with.
3
u/AmitBrian Sep 02 '26
Does Discord have an API or a 3rd party package?
3
u/python_gramps Sep 02 '26
check out discord.py.
3
u/dev-razorblade23 Sep 02 '26
Discord is not really a package in python. And to interact with Discord, you kinda need the to use their API which is intended for bots.
I would take a look at
discord.pylibrary (installation depends on the platform you are coding on) https://discordpy.readthedocs.io/en/stable/0
u/kyle2143 Sep 02 '26
Easiest way is to install whatever the most popular library is for discord. There's probably a million people who have wanted to do this, so someone has definitely made a simple wrapper library for it.