discord-protos 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/update.yml +30 -0
- package/.prettierrc.yml +3 -0
- package/LICENSE +21 -0
- package/README.md +65 -0
- package/out/FrecencyUserSettings.proto +65 -0
- package/out/PreloadedUserSettings.proto +240 -0
- package/package.json +32 -0
- package/src/index.js +51 -0
- package/src/load.js +26 -0
- package/src/parse.js +212 -0
- package/src/proto.d.ts +5657 -0
- package/src/proto.js +15375 -0
- package/src/test.js +16 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: update definitions
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
schedule:
|
|
6
|
+
- cron: "0 0 * * *"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
update:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
|
|
14
|
+
contents: write
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
|
+
with:
|
|
19
|
+
ref: ${{ github.head_ref }}
|
|
20
|
+
- uses: actions/setup-node@v3
|
|
21
|
+
with:
|
|
22
|
+
node-version: 18
|
|
23
|
+
- run: npm install
|
|
24
|
+
- run: npm run load
|
|
25
|
+
- run: npm run build
|
|
26
|
+
- run: npm run test
|
|
27
|
+
|
|
28
|
+
- uses: stefanzweifel/git-auto-commit-action@v4
|
|
29
|
+
with:
|
|
30
|
+
commit_message: Update protobuffer definitions
|
package/.prettierrc.yml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-present dolfies
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Discord Protocol Buffers
|
|
2
|
+
Reverse-engineering Discord's user settings protobufs.
|
|
3
|
+
|
|
4
|
+
This repository provides protocol buffer files for Discord's user settings automatically generated and (soon™️) automatically updated. The protobufs are provided as .proto files in the out/ directory, one file per settings type.
|
|
5
|
+
|
|
6
|
+
These protobufs are used by the Discord clients for user settings.
|
|
7
|
+
|
|
8
|
+
Provided for educational purposes only.
|
|
9
|
+
|
|
10
|
+
## Mapping
|
|
11
|
+
The following table shows which protobuf user settings correspond to which .proto file.
|
|
12
|
+
|
|
13
|
+
| Type | Value | File | Use |
|
|
14
|
+
|-------|-----------------------------------|-----------------------------|----------------------------------------------------|
|
|
15
|
+
| 1 | `PRELOADED_USER_SETTINGS` | PreloadedUserSettings.proto | General Discord user settings. |
|
|
16
|
+
| 2 | `FRECENCY_AND_FAVORITES_SETTINGS` | FrecencyUserSettings.proto | Frecency and favorites storage for various things. |
|
|
17
|
+
| 3 | `TEST_SETTINGS` | - | Unknown. |
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
### Note
|
|
21
|
+
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.
|
|
22
|
+
|
|
23
|
+
### Installation
|
|
24
|
+
```
|
|
25
|
+
# with npm
|
|
26
|
+
npm install discord-protos
|
|
27
|
+
|
|
28
|
+
# with yarn
|
|
29
|
+
yarn add discord-protos
|
|
30
|
+
|
|
31
|
+
# with pnpm
|
|
32
|
+
pnpm add discord-protos
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Example
|
|
36
|
+
```js
|
|
37
|
+
|
|
38
|
+
const DiscordProtos = require('discord-protos');
|
|
39
|
+
|
|
40
|
+
const encoded = DiscordProtos.PreloadedUserSettings.toBase64({
|
|
41
|
+
status: {
|
|
42
|
+
status: {
|
|
43
|
+
value: "online",
|
|
44
|
+
},
|
|
45
|
+
custom_status: {
|
|
46
|
+
text: "hello world",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
console.log("PreloadedUserSettings as base64", encoded);
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
const decoded = DiscordProtos.PreloadedUserSettings.fromBase64(encoded);
|
|
55
|
+
|
|
56
|
+
console.log("PreloadedUserSettings as json", encoded);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Protobufs
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
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.
|
|
63
|
+
|
|
64
|
+
### Development
|
|
65
|
+
Running script in src/parse.js will print out the protocol buffers found. You need to define a `getModules()` function for it to work. That is on you.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package discord_protos.discord_users.v1.FrecencyUserSettings;
|
|
4
|
+
|
|
5
|
+
message FrecencyUserSettings {
|
|
6
|
+
message Versions {
|
|
7
|
+
uint32 client_version = 1;
|
|
8
|
+
uint32 server_version = 2;
|
|
9
|
+
uint32 data_version = 3;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
enum GIFType {
|
|
13
|
+
NONE = 0;
|
|
14
|
+
IMAGE = 1;
|
|
15
|
+
VIDEO = 2;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message FavoriteGIF {
|
|
19
|
+
GIFType format = 1;
|
|
20
|
+
string src = 2;
|
|
21
|
+
uint32 width = 3;
|
|
22
|
+
uint32 height = 4;
|
|
23
|
+
uint32 order = 5;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
message FavoriteGIFs {
|
|
27
|
+
map<string, FavoriteGIF> gifs = 1;
|
|
28
|
+
bool hide_tooltip = 2;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
message FavoriteStickers {
|
|
32
|
+
repeated fixed64 sticker_ids = 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
message FrecencyItem {
|
|
36
|
+
uint32 total_uses = 1;
|
|
37
|
+
repeated uint64 recent_uses = 2;
|
|
38
|
+
int32 frecency = 3;
|
|
39
|
+
int32 score = 4;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
message StickerFrecency {
|
|
43
|
+
map<fixed64, FrecencyItem> stickers = 1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
message FavoriteEmojis {
|
|
47
|
+
repeated string emojis = 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
message EmojiFrecency {
|
|
51
|
+
map<string, FrecencyItem> emojis = 1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
message ApplicationCommandFrecency {
|
|
55
|
+
map<string, FrecencyItem> application_commands = 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
optional Versions versions = 1;
|
|
59
|
+
optional FavoriteGIFs favorite_gifs = 2;
|
|
60
|
+
optional FavoriteStickers favorite_stickers = 3;
|
|
61
|
+
optional StickerFrecency sticker_frecency = 4;
|
|
62
|
+
optional FavoriteEmojis favorite_emojis = 5;
|
|
63
|
+
optional EmojiFrecency emoji_frecency = 6;
|
|
64
|
+
optional ApplicationCommandFrecency application_command_frecency = 7;
|
|
65
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
import "google/protobuf/wrappers.proto";
|
|
4
|
+
import "google/protobuf/timestamp.proto";
|
|
5
|
+
|
|
6
|
+
package discord_protos.discord_users.v1.PreloadedUserSettings;
|
|
7
|
+
|
|
8
|
+
message PreloadedUserSettings {
|
|
9
|
+
message Versions {
|
|
10
|
+
uint32 client_version = 1;
|
|
11
|
+
uint32 server_version = 2;
|
|
12
|
+
uint32 data_version = 3;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
enum InboxTab {
|
|
16
|
+
UNSPECIFIED = 0;
|
|
17
|
+
MENTIONS = 1;
|
|
18
|
+
UNREADS = 2;
|
|
19
|
+
TODOS = 3;
|
|
20
|
+
FOR_YOU = 4;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
message InboxSettings {
|
|
24
|
+
InboxTab current_tab = 1;
|
|
25
|
+
bool viewed_tutorial = 2;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
message ChannelSettings {
|
|
29
|
+
bool collapsed_in_inbox = 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
message GuildSettings {
|
|
33
|
+
map<fixed64, ChannelSettings> channels = 1;
|
|
34
|
+
uint32 hub_progress = 2;
|
|
35
|
+
uint32 guild_onboarding_progress = 3;
|
|
36
|
+
optional google.protobuf.Timestamp guild_recents_dismissed_at = 4;
|
|
37
|
+
bytes dismissed_guild_content = 5;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
message AllGuildSettings {
|
|
41
|
+
map<fixed64, GuildSettings> guilds = 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
message UserContentSettings {
|
|
45
|
+
bytes dismissed_contents = 1;
|
|
46
|
+
optional google.protobuf.StringValue last_dismissed_outbound_promotion_start_date = 2;
|
|
47
|
+
optional google.protobuf.Timestamp premium_tier_0_modal_dismissed_at = 3;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
message VideoFilterBackgroundBlur {
|
|
51
|
+
bool use_blur = 1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
message VideoFilterAsset {
|
|
55
|
+
fixed64 id = 1;
|
|
56
|
+
string asset_hash = 2;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
message SoundboardSettings {
|
|
60
|
+
float volume = 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
message VoiceAndVideoSettings {
|
|
64
|
+
VideoFilterBackgroundBlur blur = 1;
|
|
65
|
+
uint32 preset_option = 2;
|
|
66
|
+
VideoFilterAsset custom_asset = 3;
|
|
67
|
+
optional google.protobuf.BoolValue always_preview_video = 5;
|
|
68
|
+
optional google.protobuf.UInt32Value afk_timeout = 6;
|
|
69
|
+
optional google.protobuf.BoolValue stream_notifications_enabled = 7;
|
|
70
|
+
optional google.protobuf.BoolValue native_phone_integration_enabled = 8;
|
|
71
|
+
optional SoundboardSettings soundboard_settings = 9;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
message TextAndImagesSettings {
|
|
75
|
+
optional google.protobuf.StringValue diversity_surrogate = 1;
|
|
76
|
+
optional google.protobuf.BoolValue use_rich_chat_input = 2;
|
|
77
|
+
optional google.protobuf.BoolValue use_thread_sidebar = 3;
|
|
78
|
+
optional google.protobuf.StringValue render_spoilers = 4;
|
|
79
|
+
repeated string emoji_picker_collapsed_sections = 5;
|
|
80
|
+
repeated string sticker_picker_collapsed_sections = 6;
|
|
81
|
+
optional google.protobuf.BoolValue view_image_descriptions = 7;
|
|
82
|
+
optional google.protobuf.BoolValue show_command_suggestions = 8;
|
|
83
|
+
optional google.protobuf.BoolValue inline_attachment_media = 9;
|
|
84
|
+
optional google.protobuf.BoolValue inline_embed_media = 10;
|
|
85
|
+
optional google.protobuf.BoolValue gif_auto_play = 11;
|
|
86
|
+
optional google.protobuf.BoolValue render_embeds = 12;
|
|
87
|
+
optional google.protobuf.BoolValue render_reactions = 13;
|
|
88
|
+
optional google.protobuf.BoolValue animate_emoji = 14;
|
|
89
|
+
optional google.protobuf.UInt32Value animate_stickers = 15;
|
|
90
|
+
optional google.protobuf.BoolValue enable_tts_command = 16;
|
|
91
|
+
optional google.protobuf.BoolValue message_display_compact = 17;
|
|
92
|
+
optional google.protobuf.UInt32Value explicit_content_filter = 19;
|
|
93
|
+
optional google.protobuf.BoolValue view_nsfw_guilds = 20;
|
|
94
|
+
optional google.protobuf.BoolValue convert_emoticons = 21;
|
|
95
|
+
optional google.protobuf.BoolValue expression_suggestions_enabled = 22;
|
|
96
|
+
optional google.protobuf.BoolValue view_nsfw_commands = 23;
|
|
97
|
+
optional google.protobuf.BoolValue use_legacy_chat_input = 24;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
message NotificationSettings {
|
|
101
|
+
optional google.protobuf.BoolValue show_in_app_notifications = 1;
|
|
102
|
+
optional google.protobuf.BoolValue notify_friends_on_go_live = 2;
|
|
103
|
+
fixed64 notification_center_acked_before_id = 3;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
enum GuildActivityStatusRestrictionDefault {
|
|
107
|
+
OFF = 0;
|
|
108
|
+
ON_FOR_LARGE_GUILDS = 1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
message PrivacySettings {
|
|
112
|
+
optional google.protobuf.BoolValue allow_activity_party_privacy_friends = 1;
|
|
113
|
+
optional google.protobuf.BoolValue allow_activity_party_privacy_voice_channel = 2;
|
|
114
|
+
repeated fixed64 restricted_guild_ids = 3;
|
|
115
|
+
bool default_guilds_restricted = 4;
|
|
116
|
+
bool allow_accessibility_detection = 7;
|
|
117
|
+
optional google.protobuf.BoolValue detect_platform_accounts = 8;
|
|
118
|
+
optional google.protobuf.BoolValue passwordless = 9;
|
|
119
|
+
optional google.protobuf.BoolValue contact_sync_enabled = 10;
|
|
120
|
+
optional google.protobuf.UInt32Value friend_source_flags = 11;
|
|
121
|
+
optional google.protobuf.UInt32Value friend_discovery_flags = 12;
|
|
122
|
+
repeated fixed64 activity_restricted_guild_ids = 13;
|
|
123
|
+
GuildActivityStatusRestrictionDefault default_guilds_activity_restricted = 14;
|
|
124
|
+
repeated fixed64 activity_joining_restricted_guild_ids = 15;
|
|
125
|
+
repeated fixed64 message_request_restricted_guild_ids = 16;
|
|
126
|
+
optional google.protobuf.BoolValue default_message_request_restricted = 17;
|
|
127
|
+
optional google.protobuf.BoolValue drops_opted_out = 18;
|
|
128
|
+
optional google.protobuf.BoolValue non_spam_retraining_opt_in = 19;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
message DebugSettings {
|
|
132
|
+
optional google.protobuf.BoolValue rtc_panel_show_voice_states = 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
message GameLibrarySettings {
|
|
136
|
+
optional google.protobuf.BoolValue install_shortcut_desktop = 1;
|
|
137
|
+
optional google.protobuf.BoolValue install_shortcut_start_menu = 2;
|
|
138
|
+
optional google.protobuf.BoolValue disable_games_tab = 3;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
message CustomStatus {
|
|
142
|
+
string text = 1;
|
|
143
|
+
fixed64 emoji_id = 2;
|
|
144
|
+
string emoji_name = 3;
|
|
145
|
+
fixed64 expires_at_ms = 4;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
message StatusSettings {
|
|
149
|
+
optional google.protobuf.StringValue status = 1;
|
|
150
|
+
optional CustomStatus custom_status = 2;
|
|
151
|
+
optional google.protobuf.BoolValue show_current_game = 3;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
message LocalizationSettings {
|
|
155
|
+
optional google.protobuf.StringValue locale = 1;
|
|
156
|
+
optional google.protobuf.Int32Value timezone_offset = 2;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
enum Theme {
|
|
160
|
+
UNSET = 0;
|
|
161
|
+
DARK = 1;
|
|
162
|
+
LIGHT = 2;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
message ClientThemeSettings {
|
|
166
|
+
optional google.protobuf.UInt64Value primary_color = 1;
|
|
167
|
+
optional google.protobuf.UInt32Value background_gradient_preset_id = 2;
|
|
168
|
+
optional google.protobuf.FloatValue background_gradient_angle = 3;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
message AppearanceSettings {
|
|
172
|
+
Theme theme = 1;
|
|
173
|
+
bool developer_mode = 2;
|
|
174
|
+
optional ClientThemeSettings client_theme_settings = 3;
|
|
175
|
+
bool mobile_redesign_disabled = 4;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
message GuildFolder {
|
|
179
|
+
repeated fixed64 guild_ids = 1;
|
|
180
|
+
optional google.protobuf.Int64Value id = 2;
|
|
181
|
+
optional google.protobuf.StringValue name = 3;
|
|
182
|
+
optional google.protobuf.UInt64Value color = 4;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
message GuildFolders {
|
|
186
|
+
repeated GuildFolder folders = 1;
|
|
187
|
+
repeated fixed64 guild_positions = 2;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
enum FavoriteChannelType {
|
|
191
|
+
UNSET_FAVORITE_CHANNEL_TYPE = 0;
|
|
192
|
+
REFERENCE_ORIGINAL = 1;
|
|
193
|
+
CATEGORY = 2;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
message FavoriteChannel {
|
|
197
|
+
string nickname = 1;
|
|
198
|
+
FavoriteChannelType type = 2;
|
|
199
|
+
uint32 position = 3;
|
|
200
|
+
fixed64 parent_id = 4;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
message Favorites {
|
|
204
|
+
map<fixed64, FavoriteChannel> favorite_channels = 1;
|
|
205
|
+
bool muted = 2;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
message AudioContextSetting {
|
|
209
|
+
bool muted = 1;
|
|
210
|
+
float volume = 2;
|
|
211
|
+
fixed64 modified_at = 3;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
message AudioSettings {
|
|
215
|
+
map<fixed64, AudioContextSetting> user = 1;
|
|
216
|
+
map<fixed64, AudioContextSetting> stream = 2;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
message CommunitiesSettings {
|
|
220
|
+
optional google.protobuf.BoolValue disable_home_auto_nav = 1;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
optional Versions versions = 1;
|
|
224
|
+
optional InboxSettings inbox = 2;
|
|
225
|
+
optional AllGuildSettings guilds = 3;
|
|
226
|
+
optional UserContentSettings user_content = 4;
|
|
227
|
+
optional VoiceAndVideoSettings voice_and_video = 5;
|
|
228
|
+
optional TextAndImagesSettings text_and_images = 6;
|
|
229
|
+
optional NotificationSettings notifications = 7;
|
|
230
|
+
optional PrivacySettings privacy = 8;
|
|
231
|
+
optional DebugSettings debug = 9;
|
|
232
|
+
optional GameLibrarySettings game_library = 10;
|
|
233
|
+
optional StatusSettings status = 11;
|
|
234
|
+
optional LocalizationSettings localization = 12;
|
|
235
|
+
optional AppearanceSettings appearance = 13;
|
|
236
|
+
optional GuildFolders guild_folders = 14;
|
|
237
|
+
optional Favorites favorites = 15;
|
|
238
|
+
optional AudioSettings audio_context_settings = 16;
|
|
239
|
+
optional CommunitiesSettings communities = 17;
|
|
240
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "discord-protos",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A parser for Discord's protobufs",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"packageManager": "pnpm@7.14.2",
|
|
7
|
+
"contributors": [
|
|
8
|
+
{
|
|
9
|
+
"name": "dolfies",
|
|
10
|
+
"email": "jeyalfie47@gmail.com",
|
|
11
|
+
"url": "https://github.com/dolfies"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Samuel Scheit",
|
|
15
|
+
"email": "github@samuelscheit.com",
|
|
16
|
+
"url": "https://samuelscheit.com"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "pbjs -t static-module --keep-case -w commonjs -o src/proto.js out/*.proto && pbts -o src/proto.d.ts src/proto.js",
|
|
22
|
+
"load": "node src/load.js",
|
|
23
|
+
"test": "node src/test.js"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"protobufjs-cli": "^1.1.1",
|
|
27
|
+
"puppeteer": "^19.7.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"protobufjs": "^7.2.2"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const proto = require("./proto");
|
|
2
|
+
|
|
3
|
+
function toBase64(data) {
|
|
4
|
+
return Buffer.from(this.encode(data).finish()).toString("base64");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function fromBase64(base64) {
|
|
8
|
+
return this.decode(Buffer.from(base64, "base64")).toJSON();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
class PreloadedUserSettings extends proto.discord_protos.discord_users.v1.PreloadedUserSettings.PreloadedUserSettings {
|
|
12
|
+
/**
|
|
13
|
+
* @param {proto.discord_protos.discord_users.v1.PreloadedUserSettings.IPreloadedUserSettings} data
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
static toBase64(data) {
|
|
17
|
+
return toBase64.call(this, data);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} base64
|
|
22
|
+
* @returns {proto.discord_protos.discord_users.v1.PreloadedUserSettings.PreloadedUserSettings}
|
|
23
|
+
*/
|
|
24
|
+
static fromBase64(base64) {
|
|
25
|
+
return fromBase64.call(this, base64);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class FrecencyUserSettings extends proto.discord_protos.discord_users.v1.FrecencyUserSettings.FrecencyUserSettings {
|
|
30
|
+
/**
|
|
31
|
+
* @param {proto.discord_protos.discord_users.v1.FrecencyUserSettings.IFrecencyUserSettings} data
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
static toBase64(data) {
|
|
35
|
+
return toBase64.call(this, data);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} base64
|
|
40
|
+
* @returns {proto.discord_protos.discord_users.v1.FrecencyUserSettings.FrecencyUserSettings}
|
|
41
|
+
*/
|
|
42
|
+
static fromBase64(base64) {
|
|
43
|
+
return fromBase64.call(this, base64);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
PreloadedUserSettings,
|
|
49
|
+
FrecencyUserSettings,
|
|
50
|
+
...proto.discord_protos,
|
|
51
|
+
};
|
package/src/load.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const puppeteer = require("puppeteer");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const { join } = require("path");
|
|
4
|
+
const script = fs.readFileSync(join(__dirname, "parse.js"), "utf8");
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const browser = await puppeteer.launch({
|
|
8
|
+
headless: true,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const page = await browser.newPage();
|
|
12
|
+
await page.goto("https://discord.com/app", { waitUntil: "networkidle0" });
|
|
13
|
+
|
|
14
|
+
const protos = await page.evaluate(`${script}; protos`);
|
|
15
|
+
|
|
16
|
+
for (const [name, proto] of Object.entries(protos)) {
|
|
17
|
+
fs.writeFileSync(
|
|
18
|
+
join(__dirname, "..", "out", name + ".proto"),
|
|
19
|
+
proto.data,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
await browser.close();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
main();
|