# Discord Protocol Buffers
Reverse-engineering Discord's user settings protobufs.
This repository provides protocol buffer files for Discord's user settings automatically generated and automatically updated. The protobufs are provided as .proto files in the out/ directory, one file per settings type.
These protobufs are used by the Discord clients for user settings.
Provided for educational purposes only.
## Usage
### Note
Automating user accounts is against the Discord ToS. This repository is a proof of concept and I cannot recommend using it. Do so at your own risk.
### Installation
```
# with npm
npm install discord-protos
# with yarn
yarn add discord-protos
# with pnpm
pnpm add discord-protos
# with pip
pip install discord-protos
```
### Example
JavaScript:
```js
const { PreloadedUserSettings } = require('discord-protos');
const encoded = PreloadedUserSettings.toBase64({
status: {
status: {
value: "online",
},
customStatus: {
text: "Hello World",
emojiId: 0n,
emojiName: "",
expiresAtMs: 0n,
},
},
});
const decoded = PreloadedUserSettings.fromBase64(encoded);
console.log(encoded, decoded);
```
Python:
```py
import base64
from discord_protos import PreloadedUserSettings
settings = PreloadedUserSettings()
encoded = base64.b64encode(settings.ParseDict({
'status': {
'status': {
'value': 'online',
},
'custom_status': {
'text': 'Hello World',
'emoji_id': 0,
'emoji_name': '',
'expires_at_ms': 0,
},
},
}).SerializeToString())
decoded = PreloadedUserSettings.FromString(base64.b64decode(encoded))
print(encoded, decoded)
```
## Mapping
The following table shows which protobuf user settings correspond to which .proto file (the Python package also provides a `UserSettingsType` enum for convenience).
| Type | Value | File | Use |
| ---- | --------------------------------- | --------------------------- | -------------------------------------------------- |
| 1 | `PRELOADED_USER_SETTINGS` | PreloadedUserSettings.proto | General Discord user settings. |
| 2 | `FRECENCY_AND_FAVORITES_SETTINGS` | FrecencyUserSettings.proto | Frecency and favorites storage for various things. |
| 3 | `TEST_SETTINGS` | - | Unknown. |
### Protobufs
The .proto files can be compiled down to Python or JavaScript files by running `npm run py` or `npm run js`. This requires protoc to be installed.
Base64-encoded data for these protobufs are provided by the `GET /users/@me/settings-proto/{type}` endpoint. For preloaded user settings, base64-encoded data is provided in the `user_settings_proto` key of the READY event received in the Discord Gateway, as well as in USER_SETTINGS_PROTO_UPDATE events.
### Development
Running `pnpm load` will extract and save the latest protobufs to the discord_protos/ directory.
Raw data
{
"_id": null,
"home_page": "https://github.com/dolfies/discord-protos",
"name": "discord-protos",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8.0",
"maintainer_email": "",
"keywords": "",
"author": "Dolfies",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/3a/7c/4b9eaf1f85caa5ff93caa948ee47a2fc5be2d2bbd4b60d3f989da84c8140/discord-protos-0.0.2.tar.gz",
"platform": null,
"description": "# Discord Protocol Buffers\r\nReverse-engineering Discord's user settings protobufs.\r\n\r\nThis repository provides protocol buffer files for Discord's user settings automatically generated and automatically updated. The protobufs are provided as .proto files in the out/ directory, one file per settings type.\r\n\r\nThese protobufs are used by the Discord clients for user settings.\r\n\r\nProvided for educational purposes only.\r\n\r\n## Usage\r\n### Note\r\nAutomating user accounts is against the Discord ToS. This repository is a proof of concept and I cannot recommend using it. Do so at your own risk.\r\n\r\n### Installation\r\n```\r\n# with npm\r\nnpm install discord-protos\r\n\r\n# with yarn\r\nyarn add discord-protos\r\n\r\n# with pnpm\r\npnpm add discord-protos\r\n\r\n# with pip\r\npip install discord-protos\r\n```\r\n\r\n### Example\r\nJavaScript:\r\n```js\r\nconst { PreloadedUserSettings } = require('discord-protos');\r\n\r\nconst encoded = PreloadedUserSettings.toBase64({\r\n status: {\r\n status: {\r\n value: \"online\",\r\n },\r\n customStatus: {\r\n text: \"Hello World\",\r\n emojiId: 0n,\r\n emojiName: \"\",\r\n expiresAtMs: 0n,\r\n },\r\n },\r\n});\r\n\r\nconst decoded = PreloadedUserSettings.fromBase64(encoded);\r\n\r\nconsole.log(encoded, decoded);\r\n```\r\n\r\nPython:\r\n```py\r\nimport base64\r\nfrom discord_protos import PreloadedUserSettings\r\n\r\nsettings = PreloadedUserSettings()\r\nencoded = base64.b64encode(settings.ParseDict({\r\n 'status': {\r\n 'status': {\r\n 'value': 'online',\r\n },\r\n 'custom_status': {\r\n 'text': 'Hello World',\r\n 'emoji_id': 0,\r\n 'emoji_name': '',\r\n 'expires_at_ms': 0,\r\n },\r\n },\r\n}).SerializeToString())\r\n\r\ndecoded = PreloadedUserSettings.FromString(base64.b64decode(encoded))\r\n\r\nprint(encoded, decoded)\r\n```\r\n\r\n## Mapping\r\nThe following table shows which protobuf user settings correspond to which .proto file (the Python package also provides a `UserSettingsType` enum for convenience).\r\n\r\n| Type | Value | File | Use |\r\n| ---- | --------------------------------- | --------------------------- | -------------------------------------------------- |\r\n| 1 | `PRELOADED_USER_SETTINGS` | PreloadedUserSettings.proto | General Discord user settings. |\r\n| 2 | `FRECENCY_AND_FAVORITES_SETTINGS` | FrecencyUserSettings.proto | Frecency and favorites storage for various things. |\r\n| 3 | `TEST_SETTINGS` | - | Unknown. |\r\n\r\n\r\n### Protobufs\r\nThe .proto files can be compiled down to Python or JavaScript files by running `npm run py` or `npm run js`. This requires protoc to be installed.\r\n\r\nBase64-encoded data for these protobufs are provided by the `GET /users/@me/settings-proto/{type}` endpoint. For preloaded user settings, base64-encoded data is provided in the `user_settings_proto` key of the READY event received in the Discord Gateway, as well as in USER_SETTINGS_PROTO_UPDATE events.\r\n\r\n### Development\r\nRunning `pnpm load` will extract and save the latest protobufs to the discord_protos/ directory.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Discord user settings protobufs.",
"version": "0.0.2",
"project_urls": {
"Homepage": "https://github.com/dolfies/discord-protos",
"Issue tracker": "https://github.com/dolfies/discord-protos/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3a7c4b9eaf1f85caa5ff93caa948ee47a2fc5be2d2bbd4b60d3f989da84c8140",
"md5": "1cd71dfed6c3315cd9af62250c9cc50f",
"sha256": "23953a05f32beedb40b708ec4b457530a6196a49c8d75d337ae9282a2a41c997"
},
"downloads": -1,
"filename": "discord-protos-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "1cd71dfed6c3315cd9af62250c9cc50f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.0",
"size": 13394,
"upload_time": "2023-03-16T01:32:14",
"upload_time_iso_8601": "2023-03-16T01:32:14.287091Z",
"url": "https://files.pythonhosted.org/packages/3a/7c/4b9eaf1f85caa5ff93caa948ee47a2fc5be2d2bbd4b60d3f989da84c8140/discord-protos-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-16 01:32:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dolfies",
"github_project": "discord-protos",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "protobuf",
"specs": []
}
],
"lcname": "discord-protos"
}