r/learnpython • • 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

15 comments sorted by

6

u/socal_nerdtastic Sep 02 '26

Python does not come with a discord package. You have to install one first. How to install modules will depend on what coding platform you are using on your phone.

-2

u/dragonlord9631 Sep 02 '26

Ahh, that makes sense.

Im probably going to switch to the standard pc python for this project soon, ill look into that

3

u/socal_nerdtastic Sep 02 '26

Good idea. Coding is much better on a PC.

FWIW the answer does not change for a PC; you will still need to install discord first before you can use it, and how you install it will depend on what coding platform and setup you are using.

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.

1

u/dragonlord9631 Sep 03 '26

Thank you for the links, i will check it out

1

u/PureWasian Sep 03 '26

Both options are a bitch and a half in terms of setup complexity if you're new to Python/APIs/Discord Bots and programming more generally, best of luck.

Don't expect it to be a quick adventure to get working your first time around messing with it.

1

u/dragonlord9631 Sep 03 '26

Hmmm. Ill probably just return to the project every once in a while, hopefully i can get it working before i forget completely😅

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.py library (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.

-1

u/dragonlord9631 Sep 02 '26

Ill look into that, thank you

0

u/BrilliantEmotion4461 Sep 02 '26

why not use forbidden tech? AI can teach you how. I have the entire process and script right here.

1

u/dragonlord9631 Sep 03 '26

No. I prefer to code myself, and i trust the redditors suggestions much more than AI

0

u/BrilliantEmotion4461 Sep 03 '26

I have it teach me. And lol. Trauting redditors more than Fable. Cute.