https://github.com/NathaanTFM/discord-game-sdk-python
Discord Game SDK for Python
https://github.com/NathaanTFM/discord-game-sdk-python
discord discord-gamesdk python
Last synced: 21 days ago
JSON representation
Discord Game SDK for Python
- Host: GitHub
- URL: https://github.com/NathaanTFM/discord-game-sdk-python
- Owner: NathaanTFM
- License: mit
- Created: 2020-07-21T15:42:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T21:42:01.000Z (over 2 years ago)
- Last Synced: 2024-10-29T20:34:48.588Z (6 months ago)
- Topics: discord, discord-gamesdk, python
- Language: Python
- Homepage:
- Size: 72.3 KB
- Stars: 15
- Watchers: 4
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-discord - discord-game-sdk-python - Discord Game SDK for Python. (Game SDK & RPC Bindings)
README
## NOTE: Most Discord GameSDK features are going deprecated. This repo will get updated if there's any major GameSDK updates
# Discord Game SDK for Python
This is **not** a module (for an installable module, check out [LennyPhoenix's fork](https://github.com/LennyPhoenix/py-discord-sdk)).
This was made for **Python >= 3.5** and **Discord Game SDK 3.2.0**This is a **Work In Progress:** it might not work as expected or not work at all. This was made for testing purposes.
## Installation
- Download:
- [Discord Game SDK (3.2.0)](https://dl-game-sdk.discordapp.net/3.2.0/discord_game_sdk.zip)
- [Discord Game SDK for Python](https://github.com/NathaanTFM/discord-game-sdk-python/archive/master.zip)- Grab the DLL from `discord_game_sdk.zip` in the `lib` directory and put it in your project directory
- Grab the `discord` directory from `master.zip` and put it in your project directory## Documentation
If you need documentation, look at [**the official Game SDK docs**](https://discord.com/developers/docs/game-sdk/sdk-starter-guide) ; this was made following the official documentation.
## Features
* Should be working:
* **ActivityManager**
* **ImageManager**
* **NetworkManager**
* **RelationshipManager**
* **StorageManager**
* **UserManager*** Should be working, but need more testing:
* **AchievementManager** (not tested at all)
* **ApplicationManager** (especially the functions `GetTicket` and `ValidateOrExit`)
* **LobbyManager**
* **OverlayManager** (especially the new functions)
* **StoreManager** (not tested at all)
* **VoiceManager**## Contributing
The code needs **more comments, type hinting**. You can also implement the **missing features**, or add **more tests**. Feel free to open a **pull request**!
You can also **report issues**. Just open an issue and I will look into it!
## Examples
You can find more examples in the `examples/` directory.
Create a Discord instance
```python
from discord import Discord
from discord.enum import CreateFlags
import timeapp = Discord(APPLICATION_ID, CreateFlags.Default)
# Don't forget to call RunCallbacks
while 1:
time.sleep(1/10)
app.RunCallbacks()
```Get current user
```python
from discord import Discord
from discord.enum import CreateFlags
import timeapp = Discord(APPLICATION_ID, CreateFlags.Default)
userManager = app.GetUserManager()
def onCurrUserUpdate():
user = userManager.GetCurrentUser()
print(f"Current user : {user.Username}#{user.Discriminator}")
userManager.OnCurrentUserUpdate = onCurrUserUpdate# Don't forget to call RunCallbacks
while 1:
time.sleep(1/10)
app.RunCallbacks()
```Set activity
```python
from discord import Discord
from discord.model import Activity
from discord.enum import Result, CreateFlags
import timeapp = Discord(APPLICATION_ID, CreateFlags.Default)
activityManager = app.GetActivityManager()
activity = Activity()
activity.State = "Testing Game SDK"
activity.Party.Id = "my_super_party_id"
activity.Party.Size.CurrentSize = 4
activity.Party.Size.MaxSize = 8
activity.Secrets.Join = "my_super_secret"def callback(result):
if result == Result.Ok:
print("Successfully set the activity!")
else:
raise Exception(result)
activityManager.UpdateActivity(activity, callback)# Don't forget to call RunCallbacks
while 1:
time.sleep(1/10)
app.RunCallbacks()
```