#discord #discord-api #game

discord-sdk

An open implementation of the Discord Game SDK

17 releases

0.3.8 Sep 2, 2024
0.3.7 Jul 26, 2024
0.3.6 Mar 5, 2024
0.3.5 Oct 4, 2023
0.1.1 Jul 28, 2021

#217 in Web programming

Download history 159/week @ 2024-08-21 318/week @ 2024-08-28 210/week @ 2024-09-04 145/week @ 2024-09-11 169/week @ 2024-09-18 268/week @ 2024-09-25 147/week @ 2024-10-02 300/week @ 2024-10-09 179/week @ 2024-10-16 105/week @ 2024-10-23 148/week @ 2024-10-30 135/week @ 2024-11-06 165/week @ 2024-11-13 115/week @ 2024-11-20 120/week @ 2024-11-27 111/week @ 2024-12-04

531 downloads per month
Used in 4 crates

MIT/Apache

195KB
4K SLoC

⚔️ discord-sdk

An (unofficial) open source Rust implementation of the Discord Game SDK.

Embark Embark Crates.io Docs dependency status Build status

Why not use this?

  • This project is not official and is using a largely undocumented protocol that Discord could change/break at any time in the future.
  • There is already a Rust wrapper for the official Game SDK.
  • Your project is not also in Rust. We may add a C API for this crate in the future, but for now this is a Rust only project.

Why use this?

  • You use Rust for your project and want to integrate features such as rich presence/activities provided by Discord.
  • You don't want to have a dependency on a closed source, shared library.
  • You like to live dangerously (though this library does also have some automated tests!).

Implemented Features

TODO: Achievements

Activities (Rich Presence)

Commands

Events

Other

TODO: Applications

⚠️ Voice

Commands

Events

  • VOICE_SETTINGS_UPDATE_2 - Undocumented, but this event is fired for all voice settings changes, except for "Set Local Volume".

TODO: Images

⚠️ Lobbies

Commands

Events

Other

⚠️ Networking

Overlay

NOTE: These are only tested insofar as the protocol is (probably) correct, however, the overlay is currently extremely limited, and so we were unable to test that the overlay commands actually function correctly since our primary project is Vulkan.

Note, there are a few other cases that overlay will not work with. The overlay is currently not supported for Mac, games with Vulkan support, and generally old games.

Also note, the SDK itself and its documentation uses the utterly confusing terminology of Un/Locked when talking about the overlay, this crate instead uses Visibility, as in Visible or Hidden.

Commands

Events

Relationships

Commands

  • Get Relationships - NOTE: This command is not really exposed directly from the regular Game SDK, but is implicitly executed by the SDK during intialization.

Events

TODO: Storage

TODO?: Store

Users

Commands

Events

⚠️ Deprecation

This hasn't been officially announced by Discord yet, but the Voice, Lobbies, and Networking functionality will be deprecated and removed sometime in the future. Since only the lobbies functionality has been implemented thus far, we will mark that functionality as deprecated once it is official.

Testing

Unfortunately Discord does not provide a convenient way to perform automated testing, as it requires an actual working Discord application to be running and logged in, which makes automated (particularly headless) testing...annoying.

For now, it's required that you manually spin up 2 different Discord applications (eg, Stable and Canary) and log in with separate accounts on the same machine, then run one test at a time.

Activities

cargo test --features local-testing test_activity

Lobbies

NOTE: This does not test the lobby search functionality as that command seems to be non-functioning and never returns results, even if the REST equivalent does return the expected results.

cargo test --features local-testing test_lobbies

Contribution

Contributor Covenant

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started. Please also read our Contributor Terms before you make any contributions.

Any contribution intentionally submitted for inclusion in an Embark Studios project, shall comply with the Rust standard licensing model (MIT OR Apache 2.0) and therefore be dual licensed as described below, without any additional terms or conditions:

License

This contribution is dual licensed under EITHER OF

at your option.

For clarity, "your" refers to Embark or any other licensee/user of the contribution.

Dependencies

~7–17MB
~205K SLoC