-
-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathConstants.js
831 lines (790 loc) · 24.8 KB
/
Constants.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
exports.Package = require('../../package.json');
/**
* Options for a client.
* @typedef {Object} ClientOptions
* @property {string} [apiRequestMethod='sequential'] One of `sequential` or `burst`. The sequential handler executes
* all requests in the order they are triggered, whereas the burst handler runs multiple in parallel, and doesn't
* provide the guarantee of any particular order. Burst mode is more likely to hit a 429 ratelimit error by its nature,
* and is therefore slightly riskier to use.
* @property {number} [shardId=0] ID of the shard to run
* @property {number} [shardCount=0] Total number of shards
* @property {number} [messageCacheMaxSize=200] Maximum number of messages to cache per channel
* (-1 or Infinity for unlimited - don't do this without message sweeping, otherwise memory usage will climb
* indefinitely)
* @property {number} [messageCacheLifetime=0] How long a message should stay in the cache until it is considered
* sweepable (in seconds, 0 for forever)
* @property {number} [messageSweepInterval=0] How frequently to remove messages from the cache that are older than
* the message cache lifetime (in seconds, 0 for never)
* @property {boolean} [fetchAllMembers=false] Whether to cache all guild members and users upon startup, as well as
* upon joining a guild (should be avoided whenever possible)
* @property {boolean} [disableEveryone=false] Default value for {@link MessageOptions#disableEveryone}
* @property {boolean} [sync=false] Whether to periodically sync guilds (for user accounts)
* @property {number} [restWsBridgeTimeout=5000] Maximum time permitted between REST responses and their
* corresponding websocket events
* @property {number} [restTimeOffset=500] Extra time in millseconds to wait before continuing to make REST
* requests (higher values will reduce rate-limiting errors on bad connections)
* @property {WSEventType[]} [disabledEvents] An array of disabled websocket events. Events in this array will not be
* processed, potentially resulting in performance improvements for larger bots. Only disable events you are
* 100% certain you don't need, as many are important, but not obviously so. The safest one to disable with the
* most impact is typically `TYPING_START`.
* @property {WebsocketOptions} [ws] Options for the WebSocket
* @property {HTTPOptions} [http] HTTP options
*/
exports.DefaultOptions = {
apiRequestMethod: 'sequential',
shardId: 0,
shardCount: 0,
messageCacheMaxSize: 200,
messageCacheLifetime: 0,
messageSweepInterval: 0,
fetchAllMembers: false,
disableEveryone: false,
sync: false,
restWsBridgeTimeout: 5000,
disabledEvents: [],
restTimeOffset: 500,
/**
* WebSocket options (these are left as snake_case to match the API)
* @typedef {Object} WebsocketOptions
* @property {number} [large_threshold=250] Number of members in a guild to be considered large
* @property {boolean} [compress=true] Whether to compress data sent on the connection
* (defaults to `false` for browsers)
*/
ws: {
large_threshold: 250,
compress: require('os').platform() !== 'browser',
properties: {
$os: process ? process.platform : 'discord.js',
$browser: 'discord.js',
$device: 'discord.js',
$referrer: '',
$referring_domain: '',
},
version: 6,
},
/**
* HTTP options
* @typedef {Object} HTTPOptions
* @property {number} [version=7] API version to use
* @property {string} [api='https://discordapp.com/api'] Base url of the API
* @property {string} [cdn='https://cdn.discordapp.com'] Base url of the CDN
* @property {string} [invite='https://discord.gg'] Base url of invites
*/
http: {
version: 7,
host: 'https://discordapp.com',
cdn: 'https://cdn.discordapp.com',
},
};
exports.WSCodes = {
1000: 'Connection gracefully closed',
4004: 'Tried to identify with an invalid token',
4010: 'Sharding data provided was invalid',
4011: 'Shard would be on too many guilds if connected',
};
exports.Errors = {
NO_TOKEN: 'Request to use token, but token was unavailable to the client.',
NO_BOT_ACCOUNT: 'Only bot accounts are able to make use of this feature.',
NO_USER_ACCOUNT: 'Only user accounts are able to make use of this feature.',
BAD_WS_MESSAGE: 'A bad message was received from the websocket; either bad compression, or not JSON.',
TOOK_TOO_LONG: 'Something took too long to do.',
NOT_A_PERMISSION: 'Invalid permission string or number.',
INVALID_RATE_LIMIT_METHOD: 'Unknown rate limiting method.',
BAD_LOGIN: 'Incorrect login details were provided.',
INVALID_SHARD: 'Invalid shard settings were provided.',
SHARDING_REQUIRED: 'This session would have handled too many guilds - Sharding is required.',
INVALID_TOKEN: 'An invalid token was provided.',
};
const Endpoints = exports.Endpoints = {
User: userID => {
if (userID.id) userID = userID.id;
const base = `/users/${userID}`;
return {
toString: () => base,
channels: `${base}/channels`,
profile: `${base}/profile`,
relationships: `${base}/relationships`,
settings: `${base}/settings`,
Relationship: uID => `${base}/relationships/${uID}`,
Guild: guildID => ({
toString: () => `${base}/guilds/${guildID}`,
settings: `${base}/guilds/${guildID}/settings`,
}),
Note: id => `${base}/notes/${id}`,
Mentions: (limit, roles, everyone, guildID) =>
`${base}/mentions?limit=${limit}&roles=${roles}&everyone=${everyone}${guildID ? `&guild_id=${guildID}` : ''}`,
Avatar: (root, hash) => {
if (userID === '1') return hash;
return Endpoints.CDN(root).Avatar(userID, hash);
},
};
},
guilds: '/guilds',
Guild: guildID => {
if (guildID.id) guildID = guildID.id;
const base = `/guilds/${guildID}`;
return {
toString: () => base,
prune: `${base}/prune`,
embed: `${base}/embed`,
bans: `${base}/bans`,
integrations: `${base}/integrations`,
members: `${base}/members`,
channels: `${base}/channels`,
invites: `${base}/invites`,
roles: `${base}/roles`,
emojis: `${base}/emojis`,
search: `${base}/messages/search`,
voiceRegions: `${base}/regions`,
webhooks: `${base}/webhooks`,
ack: `${base}/ack`,
settings: `${base}/settings`,
auditLogs: `${base}/audit-logs`,
Emoji: emojiID => `${base}/emojis/${emojiID}`,
Icon: (root, hash) => Endpoints.CDN(root).Icon(guildID, hash),
Splash: (root, hash) => Endpoints.CDN(root).Splash(guildID, hash),
Role: roleID => `${base}/roles/${roleID}`,
Member: memberID => {
if (memberID.id) memberID = memberID.id;
const mbase = `${base}/members/${memberID}`;
return {
toString: () => mbase,
Role: roleID => `${mbase}/roles/${roleID}`,
nickname: `${base}/members/@me/nick`,
};
},
};
},
channels: '/channels',
Channel: channelID => {
if (channelID.id) channelID = channelID.id;
const base = `/channels/${channelID}`;
return {
toString: () => base,
messages: {
toString: () => `${base}/messages`,
bulkDelete: `${base}/messages/bulk-delete`,
},
invites: `${base}/invites`,
typing: `${base}/typing`,
permissions: `${base}/permissions`,
webhooks: `${base}/webhooks`,
search: `${base}/messages/search`,
pins: `${base}/pins`,
Icon: (root, hash) => Endpoints.CDN(root).GDMIcon(channelID, hash),
Pin: messageID => `${base}/pins/${messageID}`,
Recipient: recipientID => `${base}/recipients/${recipientID}`,
Message: messageID => {
if (messageID.id) messageID = messageID.id;
const mbase = `${base}/messages/${messageID}`;
return {
toString: () => mbase,
reactions: `${mbase}/reactions`,
ack: `${mbase}/ack`,
Reaction: emoji => {
const rbase = `${mbase}/reactions/${emoji}`;
return {
toString: () => rbase,
User: userID => `${rbase}/${userID}`,
};
},
};
},
};
},
Message: m => exports.Endpoints.Channel(m.channel).Message(m),
Member: m => exports.Endpoints.Guild(m.guild).Member(m),
CDN(root) {
return {
Emoji: (emojiID, format = 'png') => `${root}/emojis/${emojiID}.${format}`,
Asset: name => `${root}/assets/${name}`,
Avatar: (userID, hash) => `${root}/avatars/${userID}/${hash}.${hash.startsWith('a_') ? 'gif' : 'png?size=2048'}`,
Icon: (guildID, hash) => `${root}/icons/${guildID}/${hash}.jpg`,
AppIcon: (clientID, hash) => `${root}/app-icons/${clientID}/${hash}.png`,
AppAsset: (clientID, hash) => `${root}/app-assets/${clientID}/${hash}.png`,
GDMIcon: (channelID, hash) => `${root}/channel-icons/${channelID}/${hash}.jpg?size=2048`,
Splash: (guildID, hash) => `${root}/splashes/${guildID}/${hash}.jpg`,
};
},
OAUTH2: {
Application: appID => {
const base = `/oauth2/applications/${appID}`;
return {
toString: () => base,
resetSecret: `${base}/reset`,
resetToken: `${base}/bot/reset`,
};
},
App: appID => `/oauth2/authorize?client_id=${appID}`,
},
login: '/auth/login',
logout: '/auth/logout',
voiceRegions: '/voice/regions',
gateway: {
toString: () => '/gateway',
bot: '/gateway/bot',
},
Invite: inviteID => `/invite/${inviteID}?with_counts=true`,
inviteLink: id => `https://discord.gg/${id}`,
Webhook: (webhookID, token) => `/webhooks/${webhookID}${token ? `/${token}` : ''}`,
};
/**
* The current status of the client. Here are the available statuses:
* * READY
* * CONNECTING
* * RECONNECTING
* * IDLE
* * NEARLY
* * DISCONNECTED
* @typedef {number} Status
*/
exports.Status = {
READY: 0,
CONNECTING: 1,
RECONNECTING: 2,
IDLE: 3,
NEARLY: 4,
DISCONNECTED: 5,
};
/**
* The current status of a voice connection. Here are the available statuses:
* * CONNECTED
* * CONNECTING
* * AUTHENTICATING
* * RECONNECTING
* * DISCONNECTED
* @typedef {number} VoiceStatus
*/
exports.VoiceStatus = {
CONNECTED: 0,
CONNECTING: 1,
AUTHENTICATING: 2,
RECONNECTING: 3,
DISCONNECTED: 4,
};
exports.ChannelTypes = {
TEXT: 0,
DM: 1,
VOICE: 2,
GROUP_DM: 3,
CATEGORY: 4,
};
exports.OPCodes = {
DISPATCH: 0,
HEARTBEAT: 1,
IDENTIFY: 2,
STATUS_UPDATE: 3,
VOICE_STATE_UPDATE: 4,
VOICE_GUILD_PING: 5,
RESUME: 6,
RECONNECT: 7,
REQUEST_GUILD_MEMBERS: 8,
INVALID_SESSION: 9,
HELLO: 10,
HEARTBEAT_ACK: 11,
};
exports.VoiceOPCodes = {
IDENTIFY: 0,
SELECT_PROTOCOL: 1,
READY: 2,
HEARTBEAT: 3,
SESSION_DESCRIPTION: 4,
SPEAKING: 5,
};
exports.Events = {
RATE_LIMIT: 'rateLimit',
READY: 'ready',
RESUME: 'resume',
GUILD_CREATE: 'guildCreate',
GUILD_DELETE: 'guildDelete',
GUILD_UPDATE: 'guildUpdate',
GUILD_UNAVAILABLE: 'guildUnavailable',
GUILD_AVAILABLE: 'guildAvailable',
GUILD_MEMBER_ADD: 'guildMemberAdd',
GUILD_MEMBER_REMOVE: 'guildMemberRemove',
GUILD_MEMBER_UPDATE: 'guildMemberUpdate',
GUILD_MEMBER_AVAILABLE: 'guildMemberAvailable',
GUILD_MEMBER_SPEAKING: 'guildMemberSpeaking',
GUILD_MEMBERS_CHUNK: 'guildMembersChunk',
GUILD_ROLE_CREATE: 'roleCreate',
GUILD_ROLE_DELETE: 'roleDelete',
GUILD_ROLE_UPDATE: 'roleUpdate',
GUILD_EMOJI_CREATE: 'emojiCreate',
GUILD_EMOJI_DELETE: 'emojiDelete',
GUILD_EMOJI_UPDATE: 'emojiUpdate',
GUILD_BAN_ADD: 'guildBanAdd',
GUILD_BAN_REMOVE: 'guildBanRemove',
CHANNEL_CREATE: 'channelCreate',
CHANNEL_DELETE: 'channelDelete',
CHANNEL_UPDATE: 'channelUpdate',
CHANNEL_PINS_UPDATE: 'channelPinsUpdate',
MESSAGE_CREATE: 'message',
MESSAGE_DELETE: 'messageDelete',
MESSAGE_UPDATE: 'messageUpdate',
MESSAGE_BULK_DELETE: 'messageDeleteBulk',
MESSAGE_REACTION_ADD: 'messageReactionAdd',
MESSAGE_REACTION_REMOVE: 'messageReactionRemove',
MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll',
USER_UPDATE: 'userUpdate',
USER_NOTE_UPDATE: 'userNoteUpdate',
USER_SETTINGS_UPDATE: 'clientUserSettingsUpdate',
USER_GUILD_SETTINGS_UPDATE: 'clientUserGuildSettingsUpdate',
PRESENCE_UPDATE: 'presenceUpdate',
VOICE_STATE_UPDATE: 'voiceStateUpdate',
TYPING_START: 'typingStart',
TYPING_STOP: 'typingStop',
WEBHOOKS_UPDATE: 'webhookUpdate',
DISCONNECT: 'disconnect',
RECONNECTING: 'reconnecting',
ERROR: 'error',
WARN: 'warn',
DEBUG: 'debug',
};
/**
* The type of an activity of a users presence, e.g. `PLAYING`. Here are the available types:
* * PLAYING
* * STREAMING
* * LISTENING
* * WATCHING
* @typedef {string} ActivityType
*/
exports.ActivityTypes = [
'PLAYING',
'STREAMING',
'LISTENING',
'WATCHING',
];
exports.ActivityFlags = {
INSTANCE: 1 << 0,
JOIN: 1 << 1,
SPECTATE: 1 << 2,
JOIN_REQUEST: 1 << 3,
SYNC: 1 << 4,
PLAY: 1 << 5,
};
/**
* The type of a websocket message event, e.g. `MESSAGE_CREATE`. Here are the available events:
* * READY
* * RESUMED
* * GUILD_SYNC
* * GUILD_CREATE
* * GUILD_DELETE
* * GUILD_UPDATE
* * GUILD_MEMBER_ADD
* * GUILD_MEMBER_REMOVE
* * GUILD_MEMBER_UPDATE
* * GUILD_MEMBERS_CHUNK
* * GUILD_ROLE_CREATE
* * GUILD_ROLE_DELETE
* * GUILD_ROLE_UPDATE
* * GUILD_BAN_ADD
* * GUILD_BAN_REMOVE
* * CHANNEL_CREATE
* * CHANNEL_DELETE
* * CHANNEL_UPDATE
* * CHANNEL_PINS_UPDATE
* * MESSAGE_CREATE
* * MESSAGE_DELETE
* * MESSAGE_UPDATE
* * MESSAGE_DELETE_BULK
* * MESSAGE_REACTION_ADD
* * MESSAGE_REACTION_REMOVE
* * MESSAGE_REACTION_REMOVE_ALL
* * USER_UPDATE
* * USER_NOTE_UPDATE
* * USER_SETTINGS_UPDATE
* * PRESENCE_UPDATE
* * VOICE_STATE_UPDATE
* * TYPING_START
* * VOICE_SERVER_UPDATE
* * RELATIONSHIP_ADD
* * RELATIONSHIP_REMOVE
* * WEBHOOKS_UPDATE
* @typedef {string} WSEventType
*/
exports.WSEvents = {
READY: 'READY',
RESUMED: 'RESUMED',
GUILD_SYNC: 'GUILD_SYNC',
GUILD_CREATE: 'GUILD_CREATE',
GUILD_DELETE: 'GUILD_DELETE',
GUILD_UPDATE: 'GUILD_UPDATE',
GUILD_MEMBER_ADD: 'GUILD_MEMBER_ADD',
GUILD_MEMBER_REMOVE: 'GUILD_MEMBER_REMOVE',
GUILD_MEMBER_UPDATE: 'GUILD_MEMBER_UPDATE',
GUILD_MEMBERS_CHUNK: 'GUILD_MEMBERS_CHUNK',
GUILD_ROLE_CREATE: 'GUILD_ROLE_CREATE',
GUILD_ROLE_DELETE: 'GUILD_ROLE_DELETE',
GUILD_ROLE_UPDATE: 'GUILD_ROLE_UPDATE',
GUILD_BAN_ADD: 'GUILD_BAN_ADD',
GUILD_BAN_REMOVE: 'GUILD_BAN_REMOVE',
GUILD_EMOJIS_UPDATE: 'GUILD_EMOJIS_UPDATE',
CHANNEL_CREATE: 'CHANNEL_CREATE',
CHANNEL_DELETE: 'CHANNEL_DELETE',
CHANNEL_UPDATE: 'CHANNEL_UPDATE',
CHANNEL_PINS_UPDATE: 'CHANNEL_PINS_UPDATE',
MESSAGE_CREATE: 'MESSAGE_CREATE',
MESSAGE_DELETE: 'MESSAGE_DELETE',
MESSAGE_UPDATE: 'MESSAGE_UPDATE',
MESSAGE_DELETE_BULK: 'MESSAGE_DELETE_BULK',
MESSAGE_REACTION_ADD: 'MESSAGE_REACTION_ADD',
MESSAGE_REACTION_REMOVE: 'MESSAGE_REACTION_REMOVE',
MESSAGE_REACTION_REMOVE_ALL: 'MESSAGE_REACTION_REMOVE_ALL',
USER_UPDATE: 'USER_UPDATE',
USER_NOTE_UPDATE: 'USER_NOTE_UPDATE',
USER_SETTINGS_UPDATE: 'USER_SETTINGS_UPDATE',
USER_GUILD_SETTINGS_UPDATE: 'USER_GUILD_SETTINGS_UPDATE',
PRESENCE_UPDATE: 'PRESENCE_UPDATE',
VOICE_STATE_UPDATE: 'VOICE_STATE_UPDATE',
TYPING_START: 'TYPING_START',
VOICE_SERVER_UPDATE: 'VOICE_SERVER_UPDATE',
RELATIONSHIP_ADD: 'RELATIONSHIP_ADD',
RELATIONSHIP_REMOVE: 'RELATIONSHIP_REMOVE',
WEBHOOKS_UPDATE: 'WEBHOOKS_UPDATE',
};
/**
* The type of a message, e.g. `DEFAULT`. Here are the available types:
* * DEFAULT
* * RECIPIENT_ADD
* * RECIPIENT_REMOVE
* * CALL
* * CHANNEL_NAME_CHANGE
* * CHANNEL_ICON_CHANGE
* * PINS_ADD
* * GUILD_MEMBER_JOIN
* @typedef {string} MessageType
*/
exports.MessageTypes = [
'DEFAULT',
'RECIPIENT_ADD',
'RECIPIENT_REMOVE',
'CALL',
'CHANNEL_NAME_CHANGE',
'CHANNEL_ICON_CHANGE',
'PINS_ADD',
'GUILD_MEMBER_JOIN',
];
/**
* The type of a message notification setting. Here are the available types:
* * EVERYTHING
* * MENTIONS
* * NOTHING
* * INHERIT (only for GuildChannel)
* @typedef {string} MessageNotificationType
*/
exports.MessageNotificationTypes = [
'EVERYTHING',
'MENTIONS',
'NOTHING',
'INHERIT',
];
exports.DefaultAvatars = {
BLURPLE: '6debd47ed13483642cf09e832ed0bc1b',
GREY: '322c936a8c8be1b803cd94861bdfa868',
GREEN: 'dd4dbc0016779df1378e7812eabaa04d',
ORANGE: '0e291f67c9274a1abdddeb3fd919cbaa',
RED: '1cbd08c76f8af6dddce02c5138971129',
};
exports.ExplicitContentFilterTypes = [
'DISABLED',
'NON_FRIENDS',
'FRIENDS_AND_NON_FRIENDS',
];
exports.UserSettingsMap = {
/**
* Automatically convert emoticons in your messages to emoji
* For example, when you type `:-)` Discord will convert it to 😃
* @name ClientUserSettings#convertEmoticons
* @type {boolean}
*/
convert_emoticons: 'convertEmoticons',
/**
* If new guilds should automatically disable DMs between you and its members
* @name ClientUserSettings#defaultGuildsRestricted
* @type {boolean}
*/
default_guilds_restricted: 'defaultGuildsRestricted',
/**
* Automatically detect accounts from services like Steam and Blizzard when you open the Discord client
* @name ClientUserSettings#detectPlatformAccounts
* @type {boolean}
*/
detect_platform_accounts: 'detectPlatformAccounts',
/**
* Developer Mode exposes context menu items helpful for people writing bots using the Discord API
* @name ClientUserSettings#developerMode
* @type {boolean}
*/
developer_mode: 'developerMode',
/**
* Allow playback and usage of the `/tts` command
* @name ClientUserSettings#enableTTSCommand
* @type {boolean}
*/
enable_tts_command: 'enableTTSCommand',
/**
* The theme of the client. Either `light` or `dark`
* @name ClientUserSettings#theme
* @type {string}
*/
theme: 'theme',
/**
* Last status set in the client
* @name ClientUserSettings#status
* @type {PresenceStatus}
*/
status: 'status',
/**
* Display currently running game as status message
* @name ClientUserSettings#showCurrentGame
* @type {boolean}
*/
show_current_game: 'showCurrentGame',
/**
* Display images, videos, and lolcats when uploaded directly to Discord
* @name ClientUserSettings#inlineAttachmentMedia
* @type {boolean}
*/
inline_attachment_media: 'inlineAttachmentMedia',
/**
* Display images, videos, and lolcats when uploaded posted as links in chat
* @name ClientUserSettings#inlineEmbedMedia
* @type {boolean}
*/
inline_embed_media: 'inlineEmbedMedia',
/**
* Language the Discord client will use, as an RFC 3066 language identifier
* @name ClientUserSettings#locale
* @type {string}
*/
locale: 'locale',
/**
* Display messages in compact mode
* @name ClientUserSettings#messageDisplayCompact
* @type {boolean}
*/
message_display_compact: 'messageDisplayCompact',
/**
* Show emoji reactions on messages
* @name ClientUserSettings#renderReactions
* @type {boolean}
*/
render_reactions: 'renderReactions',
/**
* Array of snowflake IDs for guilds, in the order they appear in the Discord client
* @name ClientUserSettings#guildPositions
* @type {Snowflake[]}
*/
guild_positions: 'guildPositions',
/**
* Array of snowflake IDs for guilds which you will not recieve DMs from
* @name ClientUserSettings#restrictedGuilds
* @type {Snowflake[]}
*/
restricted_guilds: 'restrictedGuilds',
explicit_content_filter: function explicitContentFilter(type) { // eslint-disable-line func-name-matching
/**
* Safe direct messaging; force people's messages with images to be scanned before they are sent to you.
* One of `DISABLED`, `NON_FRIENDS`, `FRIENDS_AND_NON_FRIENDS`
* @name ClientUserSettings#explicitContentFilter
* @type {string}
*/
return exports.ExplicitContentFilterTypes[type];
},
friend_source_flags: function friendSources(flags) { // eslint-disable-line func-name-matching
/**
* Who can add you as a friend
* @name ClientUserSettings#friendSources
* @type {Object}
* @property {boolean} all Mutual friends and mutual guilds
* @property {boolean} mutualGuilds Only mutual guilds
* @property {boolean} mutualFriends Only mutual friends
*/
return {
all: flags.all || false,
mutualGuilds: flags.all ? true : flags.mutual_guilds || false,
mutualFriends: flags.all ? true : flags.mutualFriends || false,
};
},
};
exports.UserGuildSettingsMap = {
message_notifications: function messageNotifications(type) { // eslint-disable-line func-name-matching
/**
* The type of message that should notify you
* @name ClientUserGuildSettings#messageNotifications
* @type {MessageNotificationType}
*/
return exports.MessageNotificationTypes[type];
},
/**
* Whether to receive mobile push notifications
* @name ClientUserGuildSettings#mobilePush
* @type {boolean}
*/
mobile_push: 'mobilePush',
/**
* Whether the guild is muted
* @name ClientUserGuildSettings#muted
* @type {boolean}
*/
muted: 'muted',
/**
* Whether to suppress everyone mention
* @name ClientUserGuildSettings#suppressEveryone
* @type {boolean}
*/
suppress_everyone: 'suppressEveryone',
/**
* A collection containing all the channel overrides
* @name ClientUserGuildSettings#channelOverrides
* @type {Collection<ClientUserChannelOverride>}
*/
channel_overrides: 'channelOverrides',
};
exports.UserChannelOverrideMap = {
message_notifications: function messageNotifications(type) { // eslint-disable-line func-name-matching
/**
* The type of message that should notify you
* @name ClientUserChannelOverride#messageNotifications
* @type {MessageNotificationType}
*/
return exports.MessageNotificationTypes[type];
},
/**
* Whether the channel is muted
* @name ClientUserChannelOverride#muted
* @type {boolean}
*/
muted: 'muted',
};
exports.Colors = {
DEFAULT: 0x000000,
AQUA: 0x1ABC9C,
GREEN: 0x2ECC71,
BLUE: 0x3498DB,
PURPLE: 0x9B59B6,
LUMINOUS_VIVID_PINK: 0xE91E63,
GOLD: 0xF1C40F,
ORANGE: 0xE67E22,
RED: 0xE74C3C,
GREY: 0x95A5A6,
NAVY: 0x34495E,
DARK_AQUA: 0x11806A,
DARK_GREEN: 0x1F8B4C,
DARK_BLUE: 0x206694,
DARK_PURPLE: 0x71368A,
DARK_VIVID_PINK: 0xAD1457,
DARK_GOLD: 0xC27C0E,
DARK_ORANGE: 0xA84300,
DARK_RED: 0x992D22,
DARK_GREY: 0x979C9F,
DARKER_GREY: 0x7F8C8D,
LIGHT_GREY: 0xBCC0C0,
DARK_NAVY: 0x2C3E50,
BLURPLE: 0x7289DA,
GREYPLE: 0x99AAB5,
DARK_BUT_NOT_BLACK: 0x2C2F33,
NOT_QUITE_BLACK: 0x23272A,
};
/**
* An error encountered while performing an API request. Here are the potential errors:
* * UNKNOWN_ACCOUNT
* * UNKNOWN_APPLICATION
* * UNKNOWN_CHANNEL
* * UNKNOWN_GUILD
* * UNKNOWN_INTEGRATION
* * UNKNOWN_INVITE
* * UNKNOWN_MEMBER
* * UNKNOWN_MESSAGE
* * UNKNOWN_OVERWRITE
* * UNKNOWN_PROVIDER
* * UNKNOWN_ROLE
* * UNKNOWN_TOKEN
* * UNKNOWN_USER
* * UNKNOWN_EMOJI
* * BOT_PROHIBITED_ENDPOINT
* * BOT_ONLY_ENDPOINT
* * MAXIMUM_GUILDS
* * MAXIMUM_FRIENDS
* * MAXIMUM_PINS
* * MAXIMUM_ROLES
* * MAXIMUM_REACTIONS
* * UNAUTHORIZED
* * MISSING_ACCESS
* * INVALID_ACCOUNT_TYPE
* * CANNOT_EXECUTE_ON_DM
* * EMBED_DISABLED
* * CANNOT_EDIT_MESSAGE_BY_OTHER
* * CANNOT_SEND_EMPTY_MESSAGE
* * CANNOT_MESSAGE_USER
* * CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL
* * CHANNEL_VERIFICATION_LEVEL_TOO_HIGH
* * OAUTH2_APPLICATION_BOT_ABSENT
* * MAXIMUM_OAUTH2_APPLICATIONS
* * INVALID_OAUTH_STATE
* * MISSING_PERMISSIONS
* * INVALID_AUTHENTICATION_TOKEN
* * NOTE_TOO_LONG
* * INVALID_BULK_DELETE_QUANTITY
* * CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL
* * CANNOT_EXECUTE_ON_SYSTEM_MESSAGE
* * BULK_DELETE_MESSAGE_TOO_OLD
* * INVITE_ACCEPTED_TO_GUILD_NOT_CONTANING_BOT
* * REACTION_BLOCKED
* @typedef {string} APIError
*/
exports.APIErrors = {
UNKNOWN_ACCOUNT: 10001,
UNKNOWN_APPLICATION: 10002,
UNKNOWN_CHANNEL: 10003,
UNKNOWN_GUILD: 10004,
UNKNOWN_INTEGRATION: 10005,
UNKNOWN_INVITE: 10006,
UNKNOWN_MEMBER: 10007,
UNKNOWN_MESSAGE: 10008,
UNKNOWN_OVERWRITE: 10009,
UNKNOWN_PROVIDER: 10010,
UNKNOWN_ROLE: 10011,
UNKNOWN_TOKEN: 10012,
UNKNOWN_USER: 10013,
UNKNOWN_EMOJI: 10014,
BOT_PROHIBITED_ENDPOINT: 20001,
BOT_ONLY_ENDPOINT: 20002,
MAXIMUM_GUILDS: 30001,
MAXIMUM_FRIENDS: 30002,
MAXIMUM_PINS: 30003,
MAXIMUM_ROLES: 30005,
MAXIMUM_REACTIONS: 30010,
UNAUTHORIZED: 40001,
MISSING_ACCESS: 50001,
INVALID_ACCOUNT_TYPE: 50002,
CANNOT_EXECUTE_ON_DM: 50003,
EMBED_DISABLED: 50004,
CANNOT_EDIT_MESSAGE_BY_OTHER: 50005,
CANNOT_SEND_EMPTY_MESSAGE: 50006,
CANNOT_MESSAGE_USER: 50007,
CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL: 50008,
CHANNEL_VERIFICATION_LEVEL_TOO_HIGH: 50009,
OAUTH2_APPLICATION_BOT_ABSENT: 50010,
MAXIMUM_OAUTH2_APPLICATIONS: 50011,
INVALID_OAUTH_STATE: 50012,
MISSING_PERMISSIONS: 50013,
INVALID_AUTHENTICATION_TOKEN: 50014,
NOTE_TOO_LONG: 50015,
INVALID_BULK_DELETE_QUANTITY: 50016,
CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL: 50019,
CANNOT_EXECUTE_ON_SYSTEM_MESSAGE: 50021,
BULK_DELETE_MESSAGE_TOO_OLD: 50034,
INVITE_ACCEPTED_TO_GUILD_NOT_CONTANING_BOT: 50036,
REACTION_BLOCKED: 90001,
};
/**
* The value set for a guild's default message notifications, e.g. `ALL`. Here are the available types:
* * ALL
* * MENTIONS
* @typedef {string} DefaultMessageNotifications
*/
exports.DefaultMessageNotifications = [
'ALL',
'MENTIONS',
];