forked from abalabahaha/eris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
1613 lines (1548 loc) · 62.4 KB
/
index.d.ts
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
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare module "eris" {
// TODO good hacktoberfest PR: implement ShardManager, RequestHandler and other stuff
import { EventEmitter } from "events";
import { Readable as ReadableStream } from "stream";
import { Agent as HTTPAgent } from "http";
import { Agent as HTTPSAgent } from "https";
export const VERSION: string;
interface JSONCache { [s: string]: any; }
interface SimpleJSON {
toJSON(simple?: boolean): JSONCache;
}
interface NestedJSON {
toJSON(arg?: any, cache?: Array<string | any>): JSONCache;
}
// TODO there's also toJSON(): JSONCache, though, SimpleJSON should suffice
type TextableChannel = TextChannel | PrivateChannel | GroupChannel;
type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | PrivateChannel | GroupChannel;
type AnyGuildChannel = TextChannel | VoiceChannel | CategoryChannel;
interface CreateInviteOptions {
maxAge?: number;
maxUses?: number;
temporary?: boolean;
unique?: boolean;
}
interface Invitable {
getInvites(): Promise<Invite[]>;
createInvite(options?: CreateInviteOptions, reason?: string): Promise<Invite>;
}
interface Textable {
lastMessageID: string;
messages: Collection<Message>;
sendTyping(): Promise<void>;
getMessage(messageID: string): Promise<Message>;
getMessages(limit?: number, before?: string, after?: string, around?: string): Promise<Message[]>;
getPins(): Promise<Message[]>;
createMessage(
content: MessageContent,
file?: MessageFile,
): Promise<Message>;
editMessage(messageID: string, content: MessageContent): Promise<Message>;
pinMessage(messageID: string): Promise<void>;
unpinMessage(messageID: string): Promise<void>;
getMessageReaction(
messageID: string,
reaction: string,
limit?: number,
before?: string,
after?: string,
): Promise<User[]>;
addMessageReaction(messageID: string, reaction: string, userID?: string): Promise<void>;
removeMessageReaction(messageID: string, reaction: string, userID?: string): Promise<void>;
removeMessageReactions(messageID: string): Promise<void>;
deleteMessage(messageID: string, reason?: string): Promise<void>;
unsendMessage(messageID: string): Promise<void>;
}
interface OldCall {
participants: string[];
endedTimestamp?: number;
ringing: string[];
region: string;
unavailable: boolean;
}
interface OldChannel {
name: string;
position: string;
topic?: string;
bitrate?: number;
permissionOverwrites: Collection<PermissionOverwrite>;
}
type FriendSuggestionReasons = Array<{ type: number, platform_type: string, name: string }>;
interface MemberPartial { id: string; user: User; }
interface OldPresence {
status: string;
game?: {
name: string,
type: number,
url?: string,
};
}
interface OldVoiceState { mute: boolean; deaf: boolean; selfMute: boolean; selfDeaf: boolean; }
interface OAuthApplicationInfo {
description: string,
name: string,
owner: {
username: string,
discriminator: string,
id: string,
avatar?: string,
},
bot_public: boolean,
bot_require_code_grant: boolean,
id: string,
icon?: string,
}
// To anyone snooping around this snippet of code and wondering
// "Why didn't they use a class for this? It would make the code cleaner!"
// I could, but TypeScript isn't smart enough to properly inherit overloaded methods,
// so `on` event listeners would loose their type-safety.
interface Emittable {
// tslint:disable-next-line
on(event: string, listener: Function): this;
on(event: "ready" | "disconnect", listener: () => void): this;
on(event: "callCreate" | "callRing" | "callDelete", listener: (call: Call) => void): this;
on(
event: "callUpdate",
listener: (
call: Call,
oldCall: OldCall,
) => void,
): this;
on(event: "channelCreate" | "channelDelete", listener: (channel: AnyChannel) => void): this;
on(
event: "channelPinUpdate",
listener: (channel: TextableChannel, timestamp: number, oldTimestamp: number) => void,
): this;
on(
event: "channelRecipientAdd" | "channelRecipientRemove",
listener: (channel: GroupChannel, user: User) => void,
): this;
on(
event: "channelUpdate",
listener: (
channel: AnyChannel,
oldChannel: OldChannel,
) => void,
): this;
on(
event: "friendSuggestionCreate",
listener: (user: User, reasons: FriendSuggestionReasons) => void,
): this;
on(event: "friendSuggestionDelete", listener: (user: User) => void): this;
on(
event: "guildAvailable" | "guildBanAdd" | "guildBanRemove",
listener: (guild: Guild, user: User) => void,
): this;
on(event: "guildDelete" | "guildUnavailable" | "guildCreate", listener: (guild: Guild) => void): this;
on(event: "guildEmojisUpdate", listener: (guild: Guild, emojis: Emoji[], oldEmojis: Emoji[]) => void): this;
on(event: "guildMemberAdd", listener: (guild: Guild, member: Member) => void): this;
on(event: "guildMemberChunk", listener: (guild: Guild, members: Member[]) => void): this;
on(
event: "guildMemberRemove",
listener: (guild: Guild, member: Member | MemberPartial) => void,
): this;
on(
event: "guildMemberUpdate",
listener: (guild: Guild, member: Member, oldMember: { roles: string[], nick?: string }) => void,
): this;
on(event: "guildRoleCreate" | "guildRoleDelete", listener: (guild: Guild, role: Role) => void): this;
on(event: "guildRoleUpdate", listener: (guild: Guild, role: Role, oldRole: RoleOptions) => void): this;
on(event: "guildUpdate", listener: (guild: Guild, oldGuild: GuildOptions) => void): this;
on(event: "hello", listener: (trace: string[], id: number) => void): this;
on(event: "messageCreate", listener: (message: Message) => void): this;
on(
event: "messageDelete" | "messageReactionRemoveAll",
listener: (message: PossiblyUncachedMessage) => void,
): this;
on(event: "messageDeleteBulk", listener: (messages: PossiblyUncachedMessage[]) => void): this;
on(
event: "messageReactionAdd" | "messageReactionRemove",
listener: (message: PossiblyUncachedMessage, emoji: Emoji, userID: string) => void,
): this;
on(event: "messageUpdate", listener: (message: Message, oldMessage?: {
attachments: Attachment[],
embeds: Embed[],
content: string,
editedTimestamp?: number,
mentionedBy?: any,
tts: boolean,
mentions: string[],
roleMentions: string[],
channelMentions: string[],
}) => void): this;
on(event: "presenceUpdate", listener: (other: Member | Relationship, oldPresence?: OldPresence) => void): this;
on(event: "rawWS" | "unknown", listener: (packet: RawPacket, id: number) => void): this;
on(event: "relationshipAdd" | "relationshipRemove", listener: (relationship: Relationship) => void): this;
on(
event: "relationshipUpdate",
listener: (relationship: Relationship, oldRelationship: { type: number }) => void,
): this;
on(event: "shardPreReady" | "connect", listener: (id: number) => void): this;
on(event: "typingStart", listener: (channel: TextableChannel, user: User) => void): this;
on(event: "unavailableGuildCreate", listener: (guild: UnavailableGuild) => void): this;
on(
event: "userUpdate",
listener: (user: User, oldUser: { username: string, discriminator: string, avatar?: string }) => void,
): this;
on(event: "voiceChannelJoin", listener: (member: Member, newChannel: VoiceChannel) => void): this;
on(event: "voiceChannelLeave", listener: (member: Member, oldChannel: VoiceChannel) => void): this;
on(
event: "voiceChannelSwitch",
listener: (member: Member, newChannel: VoiceChannel, oldChannel: VoiceChannel) => void,
): this;
on(
event: "voiceStateUpdate",
listener: (
member: Member,
oldState: OldVoiceState,
) => void,
): this;
on(event: "warn" | "debug", listener: (message: string, id: number) => void): this;
}
interface Constants {
DefaultAvatarHashes: string[];
ImageFormats: string[];
GatewayOPCodes: {[key: string]: number};
GATEWAY_VERSION: number;
Permissions: {[key: string]: number};
VoiceOPCodes: {[key: string]: number};
SystemJoinMessages: string[];
AuditLogActions: {[key: string]: number};
}
export const Constants: Constants;
interface WebhookPayload {
content?: string;
file?: { file: Buffer, name: string } | Array<{ file: Buffer, name: string}>;
embeds?: EmbedOptions[];
username?: string;
avatarURL?: string;
tts?: boolean;
wait?: boolean;
disableEveryone?: boolean;
}
interface EmbedBase {
title?: string;
description?: string;
url?: string;
timestamp?: string;
color?: number;
footer?: { text: string, icon_url?: string, proxy_icon_url?: string };
image?: { url?: string, proxy_url?: string, height?: number, width?: number };
thumbnail?: { url?: string, proxy_url?: string, height?: number, width?: number };
video?: { url: string, height?: number, width?: number };
provider?: { name: string, url?: string };
fields?: Array<{ name?: string, value?: string, inline?: boolean }>;
author?: { name: string, url?: string, icon_url?: string, proxy_icon_url?: string };
}
type Embed = {
type: string,
} & EmbedBase;
type EmbedOptions = {
type?: string,
} & EmbedBase;
interface Webhook {
name: string;
channel_id: string;
token: string;
avatar?: string;
guild_id: string;
id: string;
user: {
username: string,
discriminator: string,
id: string,
avatar?: string,
};
}
interface GuildEmbed {
channel_id?: string;
enabled: boolean;
}
interface Attachment { url: string; proxy_url: string; size: number; id: string; filename: string; }
interface VoiceRegion {
name: string;
deprecated: boolean;
custom: boolean;
vip: boolean;
optimal: boolean;
id: string;
}
interface UserSettings {
theme: string;
status: string;
show_current_game: boolean;
restricted_guilds: string[];
render_reactions: boolean;
render_embeds: boolean;
message_display_compact: boolean;
locale: string;
inline_embed_media: boolean;
inline_attachment_media: boolean;
guild_positions: string[];
friend_source_flags: {
all: boolean, // not sure about other keys, abal heeeelp
};
explicit_content_filter: number;
enable_tts_command: boolean;
developer_mode: boolean;
detect_platform_accounts: boolean;
default_guilds_restricted: boolean;
convert_emojis: boolean;
afk_timeout: number;
}
interface GuildSettings {
suppress_everyone: boolean;
muted: boolean;
mobile_push: boolean;
message_notifications: number;
guild_id: string;
channel_override: Array<{
muted: boolean,
message_notifications: number,
channel_id: string,
}>;
}
interface UserProfile {
premium_since?: number;
mutual_guilds: Array<{ nick?: string, id: string }>;
user: { username: string, discriminator: string, flags: number, id: string, avatar?: string };
connected_accounts: Array<{ verified: boolean, type: string, id: string, name: string }>;
}
interface Connection {
verified: boolean;
revoked: boolean;
integrations: any[]; // TODO ????
visibility: number;
friend_sync: boolean;
type: string;
id: string;
name: string;
}
interface GuildAuditLog {
users: User[];
entries: GuildAuditLogEntry[];
}
// TODO: Does this have more stuff?
interface BaseData {
id: string;
[key: string]: {};
}
type MessageContent = string | { content?: string, tts?: boolean, disableEveryone?: boolean, embed?: EmbedOptions };
interface MessageFile { file: Buffer | string; name: string; }
interface EmojiBase {
name: string;
icon?: string;
}
type EmojiOptions = {
roles?: string[],
} & EmojiBase;
type Emoji = {
roles: string[],
id: string,
require_colons: boolean,
animated: boolean,
managed: boolean,
user: { name: string, discriminator: string, id: string, avatar: string }
} & EmojiBase;
interface IntegrationOptions { expireBehavior: string; expireGracePeriod: string; enableEmoticons: string; }
interface GuildOptions {
name?: string;
region?: string;
icon?: string;
verificationLevel?: number;
defaultNotifications?: number;
explicitContentFilter?: number;
afkChannelID?: string;
afkTimeout?: number;
ownerID?: string;
splash?: string;
banner?: string;
}
interface MemberOptions { roles?: string[]; nick?: string; mute?: boolean; deaf?: boolean; channelID?: string; }
interface RoleOptions { name?: string; permissions?: number; color?: number; hoist?: boolean; mentionable?: boolean; }
interface GamePresence { name: string; type?: number; url?: string; }
interface SearchOptions {
sortBy?: string;
sortOrder?: string;
content?: string;
authorID?: string;
minID?: string;
maxID?: string;
limit?: number;
offset?: number;
contextSize?: number;
has?: string;
embedProviders?: string;
embedTypes?: string;
attachmentExtensions?: string;
attachmentFilename?: string;
channelIDs?: string[];
}
interface SearchResults { totalResults: number; results: Array<Array<Message & { hit?: boolean }>>; }
interface VoiceResourceOptions {
inlineVolume?: boolean;
voiceDataTimeout?: number;
inputArgs?: string[];
encoderArgs?: string[];
format?: string;
frameDuration?: number;
frameSize?: number;
sampleRate?: number;
}
type PossiblyUncachedMessage = Message | { id: string, channel: TextableChannel };
interface RawPacket { op: number; t?: string; d?: any; s?: number; }
interface ClientOptions {
autoreconnect?: boolean;
compress?: boolean;
connectionTimeout?: number;
disableEvents?: { [s: string]: boolean };
disableEveryone?: boolean;
firstShardID?: number;
getAllUsers?: boolean;
guildCreateTimeout?: number;
largeThreshold?: number;
lastShardID?: number;
maxShards?: number | "auto";
messageLimit?: number;
opusOnly?: boolean;
restMode?: boolean;
seedVoiceConnections?: boolean;
defaultImageFormat?: string;
defaultImageSize?: number;
ws?: any;
latencyThreshold?: number;
agent?: HTTPAgent | HTTPSAgent
}
interface CommandClientOptions {
defaultHelpCommand?: boolean;
description?: string;
ignoreBots?: boolean;
ignoreSelf?: boolean;
name?: string;
owner?: string;
prefix?: string | string[];
defaultCommandOptions?: CommandOptions;
}
interface Hooks {
preCommand?: (msg: Message, args: string[]) => void;
postCheck?: (msg: Message, args: string[], checksPassed: boolean) => void;
postExecution?: (msg: Message, args: string[], executionSuccess: boolean) => void;
postCommand?: (msg: Message, args: string[], sent?: Message) => void;
}
type GenericCheckFunction<T> = (msg: Message) => T;
interface CommandOptions {
aliases?: string[];
caseInsensitive?: boolean;
deleteCommand?: boolean;
argsRequired?: boolean;
guildOnly?: boolean;
dmOnly?: boolean;
description?: string;
fullDescription?: string;
usage?: string;
hooks?: Hooks;
requirements?: {
userIDs?: string[] | GenericCheckFunction<string[]>,
roleIDs?: string[] | GenericCheckFunction<string[]>,
roleNames?: string[] | GenericCheckFunction<string[]>,
permissions?: { [s: string]: boolean } | GenericCheckFunction<{ [s: string]: boolean }>,
custom?: GenericCheckFunction<void>,
};
cooldown?: number;
cooldownExclusions?: {
userIDs?: string[],
guildIDs?: string[],
channelIDs?: string[],
};
restartCooldown?: boolean;
cooldownReturns?: number;
cooldownMessage?: string | GenericCheckFunction<string>;
invalidUsageMessage?: string | GenericCheckFunction<string>;
permissionMessage?: string | GenericCheckFunction<string>;
errorMessage?: string | GenericCheckFunction<string>;
reactionButtons?: Array<{ emoji: string, type: string, response: CommandGenerator }>;
reactionButtonTimeout?: number;
defaultSubcommandOptions?: CommandOptions;
hidden?: boolean;
}
type CommandGeneratorFunction = (msg: Message, args: string[]) => Promise<MessageContent>
| Promise<void> | MessageContent | void;
type CommandGenerator = CommandGeneratorFunction | MessageContent | MessageContent[] | CommandGeneratorFunction[];
export class ShardManager extends Collection<Shard> {
public constructor(client: Client);
public connect(shard: Shard): void;
public spawn(id: number): void;
public toJSON(): string;
}
export class Client extends EventEmitter implements SimpleJSON, Emittable {
public token?: string;
public gatewayURL?: string;
public bot?: boolean;
public options: ClientOptions;
public channelGuildMap: { [s: string]: string };
public shards: ShardManager;
public guilds: Collection<Guild>;
public privateChannelMap: { [s: string]: string };
public privateChannels: Collection<PrivateChannel>;
public groupChannels: Collection<GroupChannel>;
public voiceConnections: Collection<VoiceConnection>;
public guildShardMap: { [s: string]: number };
public startTime: number;
public unavailableGuilds: Collection<UnavailableGuild>;
public uptime: number;
public user: ExtendedUser;
public users: Collection<User>;
public relationships: Collection<Relationship>;
public userGuildSettings: { [s: string]: GuildSettings };
public userSettings: UserSettings;
public notes: { [s: string]: string };
public constructor(token: string, options?: ClientOptions);
public connect(): Promise<void>;
public getGateway(): Promise<string>;
public getBotGateway(): Promise<{ url: string, shards: number }>;
public disconnect(options: { reconnect: boolean }): void;
public joinVoiceChannel(
channelID: string,
options?: { shared?: boolean, opusOnly?: boolean },
): Promise<VoiceConnection>;
public leaveVoiceChannel(channelID: string): void;
public closeVoiceConnection(guildID: string): void;
public editAFK(afk: boolean): void;
public editStatus(status?: string, game?: GamePresence): void;
public getChannel(channelID: string): AnyChannel;
public createChannel(
guildID: string,
name: string,
type?: number,
reason?: string,
parentID?: string,
): Promise<AnyGuildChannel>;
public editChannel(channelID: string, options: {
name?: string,
icon?: string,
ownerID?: string,
topic?: string,
bitrate?: number,
userLimit?: number,
rateLimitPerUser?: number,
nsfw?: boolean,
parentID?: string,
}, reason?: string): Promise<GroupChannel | AnyGuildChannel>;
public editChannelPosition(channelID: string, position: number): Promise<void>;
public deleteChannel(channelID: string, reason?: string): Promise<void>;
public sendChannelTyping(channelID: string): Promise<void>;
public editChannelPermission(
channelID: string,
overwriteID: string,
allow: number,
deny: number,
type: string,
reason?: string,
): Promise<void>;
public deleteChannelPermission(channelID: string, overwriteID: string, reason?: string): Promise<void>;
public getChannelInvites(channelID: string): Promise<Invite[]>;
public createChannelInvite(
channelID: string,
options?: { maxAge?: number, maxUses?: number, temporary?: boolean, unique?: boolean },
reason?: string,
): Promise<Invite>;
public getChannelWebhooks(channelID: string): Promise<Webhook[]>;
public getWebhook(webhookID: string, token?: string): Promise<Webhook>;
public createChannelWebhook(
channelID: string,
options: { name: string, avatar: string },
reason?: string,
): Promise<Webhook>;
public editWebhook(
webhookID: string,
options: { name?: string, avatar?: string },
token?: string,
reason?: string,
): Promise<Webhook>;
public executeWebhook(webhookID: string, token: string, options: WebhookPayload): Promise<void>;
public executeSlackWebhook(webhookID: string, token: string, options?: { wait?: boolean }): Promise<void>;
public deleteWebhook(webhookID: string, token?: string, reason?: string): Promise<void>;
public getGuildWebhooks(guildID: string): Promise<Webhook[]>;
public getGuildAuditLogs(
guildID: string,
limit?: number,
before?: string,
actionType?: number,
): Promise<GuildAuditLog>;
public createGuildEmoji(guildID: string, options: EmojiOptions, reason?: string): Promise<Emoji>;
public editGuildEmoji(
guildID: string,
emojiID: string,
options: { name?: string, roles?: string[] },
reason?: string,
): Promise<Emoji>;
public deleteGuildEmoji(guildID: string, emojiID: string, reason?: string): Promise<void>;
public createRole(guildID: string, options?: RoleOptions, reason?: string): Promise<Role>;
public editRole(
guildID: string,
roleID: string,
options: RoleOptions,
reason?: string,
): Promise<Role>; // TODO not all options are available?
public editRolePosition(guildID: string, roleID: string, position: number): Promise<void>;
public deleteRole(guildID: string, roleID: string, reason?: string): Promise<void>;
public getPruneCount(guildID: string, days: number): Promise<number>;
public pruneMembers(guildID: string, days: number, reason?: string): Promise<number>;
public getVoiceRegions(guildID: string): Promise<VoiceRegion[]>;
public getInvite(inviteID: string, withCounts?: boolean): Promise<Invite>;
public acceptInvite(inviteID: string): Promise<Invite>;
public deleteInvite(inviteID: string, reason?: string): Promise<void>;
public getSelf(): Promise<ExtendedUser>;
public editSelf(options: { username?: string, avatar?: string }): Promise<ExtendedUser>;
public getDMChannel(userID: string): Promise<PrivateChannel>;
public createGroupChannel(userIDs: string[]): Promise<GroupChannel>;
public getMessage(channelID: string, messageID: string): Promise<Message>;
public getMessages(
channelID: string,
limit?: number,
before?: string,
after?: string,
around?: string,
): Promise<Message[]>;
public getPins(channelID: string): Promise<Message[]>;
public createMessage(channelID: string, content: MessageContent, file?: MessageFile): Promise<Message>;
public editMessage(channelID: string, messageID: string, content: MessageContent): Promise<Message>;
public pinMessage(channelID: string, messageID: string): Promise<void>;
public unpinMessage(channelID: string, messageID: string): Promise<void>;
public getMessageReaction(
channelID: string,
messageID: string,
reaction: string,
limit?: number,
before?: string,
after?: string,
): Promise<User[]>;
public addMessageReaction(channelID: string, messageID: string, reaction: string, userID?: string): Promise<void>;
public removeMessageReaction(
channelID: string,
messageID: string,
reaction: string,
userID?: string,
): Promise<void>;
public removeMessageReactions(channelID: string, messageID: string): Promise<void>;
public deleteMessage(channelID: string, messageID: string, reason?: string): Promise<void>;
public deleteMessages(channelID: string, messageIDs: string[], reason?: string): Promise<void>;
public purgeChannel(
channelID: string,
limit?: number,
filter?: (m: Message) => boolean,
before?: string,
after?: string,
): Promise<number>;
public getGuildEmbed(guildID: string): Promise<GuildEmbed>;
public getGuildIntegrations(guildID: string): Promise<GuildIntegration[]>;
public editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise<void>;
public deleteGuildIntegration(guildID: string, integrationID: string): Promise<void>;
public syncGuildIntegration(guildID: string, integrationID: string): Promise<void>;
public getGuildInvites(guildID: string): Promise<Invite[]>;
public getGuildVanity(guildID: string): Promise<{code: Invite}>;
public banGuildMember(guildID: string, userID: string, deleteMessageDays?: number, reason?: string): Promise<void>;
public unbanGuildMember(guildID: string, userID: string, reason?: string): Promise<void>;
public createGuild(name: string, region: string, icon?: string): Promise<Guild>;
public editGuild(guildID: string, options: GuildOptions, reason?: string): Promise<Guild>;
public getGuildBans(guildID: string): Promise<Array<{ reason?: string, user: User }>>;
public getGuildBan(guildID: string, userID: string): Promise<{ reason?: string, user: User }>;
public editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise<void>;
public addGuildMemberRole(guildID: string, memberID: string, roleID: string, reason?: string): Promise<void>;
public removeGuildMemberRole(guildID: string, memberID: string, roleID: string, reason?: string): Promise<void>;
public editNickname(guildID: string, nick: string, reason?: string): Promise<void>;
public kickGuildMember(guildID: string, userID: string, reason?: string): Promise<void>;
public deleteGuild(guildID: string): Promise<void>;
public leaveGuild(guildID: string): Promise<void>;
public getOAuthApplication(appID?: string): Promise<OAuthApplicationInfo>;
public addRelationship(userID: string, block?: boolean): Promise<void>;
public removeRelationship(userID: string): Promise<void>;
public addGroupRecipient(groupID: string, userID: string): Promise<void>;
public removeGroupRecipient(groupID: string, userID: string): Promise<void>;
public getUserProfile(userID: string): Promise<UserProfile>;
public editUserNote(userID: string, note: string): Promise<void>;
public deleteUserNote(userID: string): Promise<void>;
public getSelfConnections(): Promise<Connection[]>;
public editSelfConnection(
platform: string,
id: string,
data: { friendSync: boolean, visibility: number },
): Promise<Connection>;
public deleteSelfConnection(platform: string, id: string): Promise<void>;
public getSelfSettings(): Promise<UserSettings>;
public editSelfSettings(data: UserSettings): Promise<UserSettings>;
public getSelfMFACodes(
password: string,
regenerate?: boolean,
): Promise<{ backup_codes: Array<{ code: string, consumed: boolean }> }>;
public enableSelfMFATOTP(
secret: string,
code: string,
): Promise<{ token: string, backup_codes: Array<{ code: string, consumed: boolean }> }>;
public disableSelfMFATOTP(code: string): Promise<{ token: string }>;
public getSelfBilling(): Promise<{
premium_subscription?: {
status: number,
ended_at?: string,
canceled_at?: string,
created_at: string,
current_period_end?: string,
current_period_start?: string,
plan: string,
},
payment_source?: {
type: string,
brand: string,
invalid: boolean,
last_4: number,
expires_year: number,
expires_month: number,
},
payment_gateway?: string,
}>;
public getSelfPayments(): Promise<Array<{
status: number,
amount_refunded: number,
description: string,
created_at: string, // date
currency: string,
amount: number,
}>>;
public addSelfPremiumSubscription(token: string, plan: string): Promise<void>;
public deleteSelfPremiumSubscription(): Promise<void>;
public getRESTChannel(channelID: string): Promise<AnyChannel>;
public getRESTGuild(guildID: string): Promise<Guild>;
public getRESTGuilds(limit?: number, before?: string, after?: string): Promise<Guild[]>;
public getRESTGuildChannels(guildID: string): Promise<AnyGuildChannel[]>;
public getRESTGuildEmojis(guildID: string): Promise<Emoji[]>;
public getRESTGuildEmoji(guildID: string, emojiID: string): Promise<Emoji>;
public getRESTGuildMembers(guildID: string, limit?: number, after?: string): Promise<Member[]>;
public getRESTGuildMember(guildID: string, memberID: string): Promise<Member>;
public getRESTGuildRoles(guildID: string): Promise<Role[]>;
public getRESTUser(userID: string): Promise<User>;
public searchChannelMessages(channelID: string, query: SearchOptions): Promise<SearchResults>;
public searchGuildMessages(guildID: string, query: SearchOptions): Promise<SearchResults>;
// tslint:disable-next-line
public on(event: string, listener: Function): this;
public on(event: "ready" | "disconnect", listener: () => void): this;
public on(event: "callCreate" | "callRing" | "callDelete", listener: (call: Call) => void): this;
public on(
event: "callUpdate",
listener: (
call: Call,
oldCall: OldCall,
) => void,
): this;
public on(event: "channelCreate" | "channelDelete", listener: (channel: AnyChannel) => void): this;
public on(
event: "channelPinUpdate",
listener: (channel: TextableChannel, timestamp: number, oldTimestamp: number) => void,
): this;
public on(
event: "channelRecipientAdd" | "channelRecipientRemove",
listener: (channel: GroupChannel, user: User) => void,
): this;
public on(
event: "channelUpdate",
listener: (
channel: AnyChannel,
oldChannel: OldChannel,
) => void,
): this;
public on(
event: "friendSuggestionCreate",
listener: (user: User, reasons: FriendSuggestionReasons) => void,
): this;
public on(event: "friendSuggestionDelete", listener: (user: User) => void): this;
public on(
event: "guildAvailable" | "guildBanAdd" | "guildBanRemove",
listener: (guild: Guild, user: User) => void,
): this;
public on(event: "guildDelete" | "guildUnavailable" | "guildCreate", listener: (guild: Guild) => void): this;
public on(event: "guildEmojisUpdate", listener: (guild: Guild, emojis: Emoji[], oldEmojis: Emoji[]) => void): this;
public on(event: "guildMemberAdd", listener: (guild: Guild, member: Member) => void): this;
public on(event: "guildMemberChunk", listener: (guild: Guild, members: Member[]) => void): this;
public on(
event: "guildMemberRemove",
listener: (guild: Guild, member: Member | MemberPartial) => void,
): this;
public on(
event: "guildMemberUpdate",
listener: (guild: Guild, member: Member, oldMember: { roles: string[], nick?: string }) => void,
): this;
public on(event: "guildRoleCreate" | "guildRoleDelete", listener: (guild: Guild, role: Role) => void): this;
public on(event: "guildRoleUpdate", listener: (guild: Guild, role: Role, oldRole: RoleOptions) => void): this;
public on(event: "guildUpdate", listener: (guild: Guild, oldGuild: GuildOptions) => void): this;
public on(event: "hello", listener: (trace: string[], id: number) => void): this;
public on(event: "messageCreate", listener: (message: Message) => void): this;
public on(
event: "messageDelete" | "messageReactionRemoveAll",
listener: (message: PossiblyUncachedMessage) => void,
): this;
public on(event: "messageDeleteBulk", listener: (messages: PossiblyUncachedMessage[]) => void): this;
public on(
event: "messageReactionAdd" | "messageReactionRemove",
listener: (message: PossiblyUncachedMessage, emoji: Emoji, userID: string) => void,
): this;
public on(event: "messageUpdate", listener: (message: Message, oldMessage?: {
attachments: Attachment[],
embeds: Embed[],
content: string,
editedTimestamp?: number,
mentionedBy?: any,
tts: boolean,
mentions: string[],
roleMentions: string[],
channelMentions: string[],
}) => void): this;
public on(
event: "presenceUpdate",
listener: (
other: Member | Relationship,
oldPresence?: OldPresence,
) => void,
): this;
public on(event: "rawWS" | "unknown", listener: (packet: RawPacket, id: number) => void): this;
public on(event: "relationshipAdd" | "relationshipRemove", listener: (relationship: Relationship) => void): this;
public on(
event: "relationshipUpdate",
listener: (relationship: Relationship, oldRelationship: { type: number }) => void,
): this;
public on(event: "typingStart", listener: (channel: TextableChannel, user: User) => void): this;
public on(event: "unavailableGuildCreate", listener: (guild: UnavailableGuild) => void): this;
public on(
event: "userUpdate",
listener: (user: User, oldUser: { username: string, discriminator: string, avatar?: string }) => void,
): this;
public on(event: "voiceChannelJoin", listener: (member: Member, newChannel: VoiceChannel) => void): this;
public on(event: "voiceChannelLeave", listener: (member: Member, oldChannel: VoiceChannel) => void): this;
public on(
event: "voiceChannelSwitch",
listener: (member: Member, newChannel: VoiceChannel, oldChannel: VoiceChannel) => void,
): this;
public on(
event: "voiceStateUpdate",
listener: (
member: Member,
oldState: OldVoiceState,
) => void,
): this;
public on(event: "warn" | "debug", listener: (message: string, id: number) => void): this;
public on(
event: "shardDisconnect" | "error" | "shardPreReady" | "connect",
listener: (err: Error, id: number) => void,
): this;
public on(event: "shardReady" | "shardResume", listener: (id: number) => void): this;
public toJSON(simple?: boolean): JSONCache;
}
export class VoiceConnection extends EventEmitter implements SimpleJSON {
public id: string;
public channelID: string;
public connecting: boolean;
public ready: boolean;
public playing: boolean;
public paused: boolean;
public volume: number;
public current?: {
startTime: number,
playTime: number,
pausedTimestamp?: number,
pausedTime?: number,
options: VoiceResourceOptions,
};
public constructor(id: string, options?: { shard?: Shard, shared?: boolean, opusOnly?: boolean });
public pause(): void;
public play(resource: ReadableStream | string, options?: VoiceResourceOptions): void;
public receive(type: string): VoiceDataStream;
public resume(): void;
public setVolume(volume: number): void;
public stopPlaying(): void;
public switchChannel(channelID: string): void;
public updateVoiceState(selfMute: boolean, selfDeaf: boolean): void;
public on(event: "debug" | "warn", listener: (message: string) => void): this;
public on(event: "error" | "disconnect", listener: (err: Error) => void): this;
public on(event: "pong", listener: (latency: number) => void): this;
public on(event: "speakingStart", listener: (userID: string) => void): this;
public on(event: "speakingStop", listener: (userID: string) => void): this;
public on(event: "end", listener: () => void): this;
public toJSON(simple?: boolean): JSONCache;
}
export class SharedStream extends EventEmitter {
public playing: boolean;
public ended: boolean;
public volume: number;
public speaking: boolean;
public current?: {
startTime: number,
playTime: number,
pausedTimestamp?: number,
pausedTime?: number,
options: VoiceResourceOptions,
};
public add(connection: VoiceConnection): void;
public play(resource: ReadableStream | string, options: VoiceResourceOptions): void;
public remove(connection: VoiceConnection): void;
public setVolume(volume: number): void;
public stopPlaying(): void;
}
export class VoiceDataStream extends EventEmitter {
public type: string;
public constructor(type: string);
public on(event: "data", listener: (data: Buffer, userID: string, timestamp: number, sequence: number) => void): this;
}
// tslint:disable-next-line
export class VoiceConnectionManager<T extends VoiceConnection> extends Collection<T> implements SimpleJSON { // owo an undocumented class
public constructor(vcObject: new () => T);
public join(guildID: string, channelID: string, options: VoiceResourceOptions): Promise<VoiceConnection>;
public leave(guildID: string): void;
public switch(guildID: string, channelID: string): void;
public toJSON(simple?: boolean): JSONCache;
}
class Base implements SimpleJSON {
public id: string;
public createdAt: number;
public constructor(id: string);
public inspect(): this;
public toJSON(simple?: boolean): JSONCache;
}
export class Bucket {
public tokens: number;
public lastReset: number;
public lastSend: number;
public tokenLimit: number;
public interval: number;
public constructor(tokenLimit: number, interval: number, latencyRef: { latency: number });
// tslint:disable-next-line
public queue(func: Function): void;
}
export class Collection<T extends { id: string | number }> extends Map<string | number, T> {
public baseObject: new (...args: any[]) => T;
public limit?: number;
public constructor(baseObject: new (...args: any[]) => T, limit?: number);
public add(obj: T, extra?: any, replace?: boolean): T;
public find(func: (i: T) => boolean): T;
public random(): T;
public filter(func: (i: T) => boolean): T[];
public map<R>(func: (i: T) => R): R[];
public reduce<U>(func: (accumulator: U, val: T) => U, initial?: U): U;
public every(func: (i: T) => boolean): boolean;
public some(func: (i: T) => boolean): boolean;
public update(obj: T, extra?: any, replace?: boolean): T;
public remove(obj: T | { id: string }): T;
}
export class Call extends Base {
public id: string;
public createdAt: number;
public channel: GroupChannel;
public voiceStates: Collection<VoiceState>;
public participants: string[];
public endedTimestamp?: number;
public ringing?: string[];
public region?: string;
public unavailable: boolean;
public constructor(data: BaseData, channel: GroupChannel);
}
export class Channel extends Base {
public id: string;
public mention: string;
public type: number;
public createdAt: number;
public constructor(data: BaseData);
}
export class ExtendedUser extends User {
public email: string;
public verified: boolean;
public mfaEnabled: boolean;
}