gp-discord-python
gp-discord-python is an API wrapper for Discord, written in Python.
This library uses Oauth2 for authentication.
Installing
pip install gp-discord-python
Usage
from discord.client import Client
client = Client("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")
client.set_bot_token("YOUR_BOT_TOKEN")
To obtain and set an access token, follow this instructions:
- Get authorization URL
url = client.authorization_url(redirect_uri="YOUR_REDIRECT_URI")
# This call generates the url necessary to display the pop-up window to perform oauth authentication
# param redirect_uri is required oauth request.
- Get access token using code
token = client.exchange_code("YOUR_CODE")
# "code" is the same response code after login with oauth with the above url.
- Refresh access token using refresh_token
token = client.refresh_token("YOUR_REFRESH_TOKEN")
# "refresh_token" is the token refresh in response after login with oauth with the above url.
Actions
- Get user info
client.get_user_info()
# Get the info for current user.
- Get by URL
client.get_by_url(url="YOUR_URL")
# Get data for any other URL from Discord API.
- List of channels
client.get_channel_list(guild_id="YOUR_GUILD_ID")
# Get data list for all channels in server account connected
# param guild_id is in the response of access token after exchange code authorization.
- Get messages
client.get_messages(channel_id="YOUR_CHANNEL_ID")
# Get data list for all messages in a channel from server account connected
# param channel_id is in the response of list of channels action's.
- Send message
import json
client.send_messages(
channel_id="YOUR_CHANNEL_ID",
data=json.dumps({"content": "YOUR_MESSAGE_HERE"})
)
# Send message to channel from server account connected
# param channel_id is in the response of list of channels action's.
# param data is the content of message in format json
Metadata
Release files for gp-discord-python 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gp_discord_python-0.1.0.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gp_discord_python-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 kB
Release files / gp_discord_python-0.1.0.tar.gz
| Download URL | gp_discord_python-0.1.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
950a9f11f28dbdc70c244e2f1b9024d8ea8c9feed60b6b7d46e41c8ff25ab23c
|
|
BLAKE2b-256 checksum How to use checksums |
07793e50e4b7f65bfd1c380e97bbdd1dffc5529e6ed2b1609afcbdfc32dd0d25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.10
|
Release files / gp_discord_python-0.1.0-py3-none-any.whl
| Download URL | gp_discord_python-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58ada0ad09fe0c445d4e77eb6f62bc829831bd25b18366079f1a9a4b5d7c6f57
|
|
BLAKE2b-256 checksum How to use checksums |
65b5f751aae42a30c7f8b15d4d55d1c9a82dede835d25d728d849dc89a5c93e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.10
|