API wrapper for Discord written in Python
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gp_discord_python-0.1.0.tar.gz
.
File metadata
- Download URL: gp_discord_python-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 950a9f11f28dbdc70c244e2f1b9024d8ea8c9feed60b6b7d46e41c8ff25ab23c |
|
MD5 | 0084da969902adb85725fe5d1c8d4757 |
|
BLAKE2b-256 | 07793e50e4b7f65bfd1c380e97bbdd1dffc5529e6ed2b1609afcbdfc32dd0d25 |
File details
Details for the file gp_discord_python-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: gp_discord_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58ada0ad09fe0c445d4e77eb6f62bc829831bd25b18366079f1a9a4b5d7c6f57 |
|
MD5 | 2fb525c3dce085228847ccdc5ce0271c |
|
BLAKE2b-256 | 65b5f751aae42a30c7f8b15d4d55d1c9a82dede835d25d728d849dc89a5c93e3 |