index.d.ts 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. // Type definitions for discord.js 11.3.0
  2. // Project: https://github.com/hydrabolt/discord.js
  3. // Definitions by:
  4. // acdenisSK <acdenissk69@gmail.com> (https://github.com/acdenisSK)
  5. // Zack Campbell <zajrik@gmail.com> (https://github.com/zajrik)
  6. // License: MIT
  7. declare module 'discord.js' {
  8. import { EventEmitter } from 'events';
  9. import { Stream, Readable as ReadableStream } from 'stream';
  10. import { ChildProcess } from 'child_process';
  11. export const version: string;
  12. //#region Classes
  13. class Attachment {
  14. constructor(file: BufferResolvable | Stream, name?: string);
  15. private _attach(file: BufferResolvable | Stream, name: string): void;
  16. public readonly attachment: BufferResolvable | Stream;
  17. public readonly name: string;
  18. public setAttachment(file: BufferResolvable | Stream, name: string): this;
  19. public setFile(attachment: BufferResolvable | Stream): this;
  20. public setName(name: string): this;
  21. }
  22. class AudioPlayer extends EventEmitter {
  23. constructor(voiceConnection: VoiceConnection);
  24. public readonly dispatcher: StreamDispatcher;
  25. public opusEncoder: object;
  26. public prism: object;
  27. public readonly transcoder: object;
  28. public voiceConnection: VoiceConnection;
  29. public setBitrate(value: number | 'auto'): void;
  30. }
  31. class BaseOpus {
  32. constructor(options?: { bitrate?: number, fec?: boolean, plp?: number });
  33. public bitrate: number;
  34. public options: object;
  35. }
  36. export class CategoryChannel extends GuildChannel {
  37. public readonly children: Collection<Snowflake, GuildChannel>;
  38. }
  39. export class Channel {
  40. constructor(client: Client, data: object);
  41. public readonly client: Client;
  42. public readonly createdAt: Date;
  43. public readonly createdTimestamp: number;
  44. public id: Snowflake;
  45. public type: 'dm' | 'group' | 'text' | 'voice' | 'category';
  46. public delete(): Promise<Channel>;
  47. }
  48. export class Client extends EventEmitter {
  49. constructor(options?: ClientOptions);
  50. private _intervals: Set<NodeJS.Timer>;
  51. private _pingTimestamp: number;
  52. private _timeouts: Set<NodeJS.Timer>;
  53. private actions: object;
  54. private dataManager: object;
  55. private manager: ClientManager;
  56. private resolver: ClientDataResolver;
  57. private rest: object;
  58. private voice: ClientVoiceManager;
  59. private ws: object;
  60. private _eval(script: string): any;
  61. private _pong(startTime: number): void;
  62. private _setPresence(id: Snowflake, presence: object): void;
  63. private _validateOptions(options?: ClientOptions): void;
  64. public broadcasts: VoiceBroadcast[];
  65. public readonly browser: boolean;
  66. public channels: Collection<Snowflake, Channel>;
  67. public readonly emojis: Collection<Snowflake, Emoji>;
  68. public guilds: Collection<Snowflake, Guild>;
  69. public options: ClientOptions;
  70. public readonly ping: number;
  71. public pings: number[];
  72. public presences: Collection<Snowflake, Presence>;
  73. public readyAt: Date;
  74. public readonly readyTimestamp: number;
  75. public shard: ShardClientUtil;
  76. public readonly status: number;
  77. public token: string;
  78. public readonly uptime: number;
  79. public user: ClientUser;
  80. public users: Collection<Snowflake, User>;
  81. public readonly voiceConnections: Collection<Snowflake, VoiceConnection>;
  82. public clearInterval(interval: NodeJS.Timer): void;
  83. public clearTimeout(timeout: NodeJS.Timer): void;
  84. public createVoiceBroadcast(): VoiceBroadcast;
  85. public destroy(): Promise<void>;
  86. public fetchApplication(id?: Snowflake): Promise<OAuth2Application>;
  87. public fetchInvite(invite: InviteResolvable): Promise<Invite>;
  88. public fetchUser(id: Snowflake, cache?: boolean): Promise<User>;
  89. public fetchVoiceRegions(): Promise<Collection<string, VoiceRegion>>;
  90. public fetchWebhook(id: Snowflake, token?: string): Promise<Webhook>;
  91. public generateInvite(permissions?: PermissionResolvable[] | number): Promise<string>;
  92. public login(token?: string): Promise<string>;
  93. public setInterval(fn: Function, delay: number, ...args: any[]): NodeJS.Timer;
  94. public setTimeout(fn: Function, delay: number, ...args: any[]): NodeJS.Timer;
  95. public sweepMessages(lifetime?: number): number;
  96. public syncGuilds(guilds?: Guild[] | Collection<Snowflake, Guild>): void;
  97. public on(event: 'channelCreate', listener: (channel: Channel) => void): this;
  98. public on(event: 'channelDelete', listener: (channel: Channel) => void): this;
  99. public on(event: 'channelPinsUpdate', listener: (channel: Channel, time: Date) => void): this;
  100. public on(event: 'channelUpdate', listener: (oldChannel: Channel, newChannel: Channel) => void): this;
  101. public on(event: 'clientUserGuildSettingsUpdate', listener: (clientUserGuildSettings: ClientUserGuildSettings) => void): this;
  102. public on(event: 'clientUserSettingsUpdate', listener: (clientUserSettings: ClientUserSettings) => void): this;
  103. public on(event: 'debug', listener: (info: string) => void): this;
  104. public on(event: 'disconnect', listener: (event: any) => void): this;
  105. public on(event: 'emojiCreate', listener: (emoji: Emoji) => void): this;
  106. public on(event: 'emojiDelete', listener: (emoji: Emoji) => void): this;
  107. public on(event: 'emojiUpdate', listener: (oldEmoji: Emoji, newEmoji: Emoji) => void): this;
  108. public on(event: 'error', listener: (error: Error) => void): this;
  109. public on(event: 'guildBanAdd', listener: (guild: Guild, user: User) => void): this;
  110. public on(event: 'guildBanRemove', listener: (guild: Guild, user: User) => void): this;
  111. public on(event: 'guildCreate', listener: (guild: Guild) => void): this;
  112. public on(event: 'guildDelete', listener: (guild: Guild) => void): this;
  113. public on(event: 'guildMemberAdd', listener: (member: GuildMember) => void): this;
  114. public on(event: 'guildMemberAvailable', listener: (member: GuildMember) => void): this;
  115. public on(event: 'guildMemberRemove', listener: (member: GuildMember) => void): this;
  116. public on(event: 'guildMembersChunk', listener: (members: GuildMember[], guild: Guild) => void): this;
  117. public on(event: 'guildMemberSpeaking', listener: (member: GuildMember, speaking: boolean) => void): this;
  118. public on(event: 'guildMemberUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this;
  119. public on(event: 'guildUnavailable', listener: (guild: Guild) => void): this;
  120. public on(event: 'guildUpdate', listener: (oldGuild: Guild, newGuild: Guild) => void): this;
  121. public on(event: 'message', listener: (message: Message) => void): this;
  122. public on(event: 'messageDelete', listener: (message: Message) => void): this;
  123. public on(event: 'messageDeleteBulk', listener: (messages: Collection<Snowflake, Message>) => void): this;
  124. public on(event: 'messageReactionAdd', listener: (messageReaction: MessageReaction, user: User) => void): this;
  125. public on(event: 'messageReactionRemove', listener: (messageReaction: MessageReaction, user: User) => void): this;
  126. public on(event: 'messageReactionRemoveAll', listener: (message: Message) => void): this;
  127. public on(event: 'messageUpdate', listener: (oldMessage: Message, newMessage: Message) => void): this;
  128. public on(event: 'presenceUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this;
  129. public on(event: 'ready', listener: () => void): this;
  130. public on(event: 'reconnecting', listener: () => void): this;
  131. public on(event: 'resume', listener: (replayed: number) => void): this;
  132. public on(event: 'roleCreate', listener: (role: Role) => void): this;
  133. public on(event: 'roleDelete', listener: (role: Role) => void): this;
  134. public on(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this;
  135. public on(event: 'typingStart', listener: (channel: Channel, user: User) => void): this;
  136. public on(event: 'typingStop', listener: (channel: Channel, user: User) => void): this;
  137. public on(event: 'userNoteUpdate', listener: (user: UserResolvable, oldNote: string, newNote: string) => void): this;
  138. public on(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this;
  139. public on(event: 'voiceStateUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this;
  140. public on(event: 'warn', listener: (info: string) => void): this;
  141. public on(event: string, listener: Function): this;
  142. public once(event: 'channelCreate', listener: (channel: Channel) => void): this;
  143. public once(event: 'channelDelete', listener: (channel: Channel) => void): this;
  144. public once(event: 'channelPinsUpdate', listener: (channel: Channel, time: Date) => void): this;
  145. public once(event: 'channelUpdate', listener: (oldChannel: Channel, newChannel: Channel) => void): this;
  146. public once(event: 'clientUserGuildSettingsUpdate', listener: (clientUserGuildSettings: ClientUserGuildSettings) => void): this;
  147. public once(event: 'clientUserSettingsUpdate', listener: (clientUserSettings: ClientUserSettings) => void): this;
  148. public once(event: 'debug', listener: (info: string) => void): this;
  149. public once(event: 'disconnect', listener: (event: any) => void): this;
  150. public once(event: 'emojiCreate', listener: (emoji: Emoji) => void): this;
  151. public once(event: 'emojiDelete', listener: (emoji: Emoji) => void): this;
  152. public once(event: 'emojiUpdate', listener: (oldEmoji: Emoji, newEmoji: Emoji) => void): this;
  153. public once(event: 'error', listener: (error: Error) => void): this;
  154. public once(event: 'guildBanAdd', listener: (guild: Guild, user: User) => void): this;
  155. public once(event: 'guildBanRemove', listener: (guild: Guild, user: User) => void): this;
  156. public once(event: 'guildCreate', listener: (guild: Guild) => void): this;
  157. public once(event: 'guildDelete', listener: (guild: Guild) => void): this;
  158. public once(event: 'guildMemberAdd', listener: (member: GuildMember) => void): this;
  159. public once(event: 'guildMemberAvailable', listener: (member: GuildMember) => void): this;
  160. public once(event: 'guildMemberRemove', listener: (member: GuildMember) => void): this;
  161. public once(event: 'guildMembersChunk', listener: (members: GuildMember[], guild: Guild) => void): this;
  162. public once(event: 'guildMemberSpeaking', listener: (member: GuildMember, speaking: boolean) => void): this;
  163. public once(event: 'guildMemberUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this;
  164. public once(event: 'guildUnavailable', listener: (guild: Guild) => void): this;
  165. public once(event: 'guildUpdate', listener: (oldGuild: Guild, newGuild: Guild) => void): this;
  166. public once(event: 'message', listener: (message: Message) => void): this;
  167. public once(event: 'messageDelete', listener: (message: Message) => void): this;
  168. public once(event: 'messageDeleteBulk', listener: (messages: Collection<Snowflake, Message>) => void): this;
  169. public once(event: 'messageReactionAdd', listener: (messageReaction: MessageReaction, user: User) => void): this;
  170. public once(event: 'messageReactionRemove', listener: (messageReaction: MessageReaction, user: User) => void): this;
  171. public once(event: 'messageReactionRemoveAll', listener: (message: Message) => void): this;
  172. public once(event: 'messageUpdate', listener: (oldMessage: Message, newMessage: Message) => void): this;
  173. public once(event: 'presenceUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this;
  174. public once(event: 'ready', listener: () => void): this;
  175. public once(event: 'reconnecting', listener: () => void): this;
  176. public once(event: 'resume', listener: (replayed: number) => void): this;
  177. public once(event: 'roleCreate', listener: (role: Role) => void): this;
  178. public once(event: 'roleDelete', listener: (role: Role) => void): this;
  179. public once(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this;
  180. public once(event: 'typingStart', listener: (channel: Channel, user: User) => void): this;
  181. public once(event: 'typingStop', listener: (channel: Channel, user: User) => void): this;
  182. public once(event: 'userNoteUpdate', listener: (user: UserResolvable, oldNote: string, newNote: string) => void): this;
  183. public once(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this;
  184. public once(event: 'voiceStateUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this;
  185. public once(event: 'warn', listener: (info: string) => void): this;
  186. public once(event: string, listener: Function): this;
  187. }
  188. class ClientDataResolver {
  189. constructor(client: Client);
  190. public resolveBase64(data: Base64Resolvable): string;
  191. public resolveChannel(channel: ChannelResolvable): Channel;
  192. public resolveChannelID(channel: ChannelResolvable): Snowflake;
  193. public resolveColor(color: ColorResolvable): number;
  194. public resolveEmojiIdentifier(emoji: EmojiIdentifierResolvable): string;
  195. public resolveFile(resource: BufferResolvable | Stream): Promise<Buffer>;
  196. public resolveGuild(guild: GuildResolvable): Guild;
  197. public resolveGuildMember(guild: GuildResolvable, user: UserResolvable): GuildMember;
  198. public resolveImage(imge: BufferResolvable | Base64Resolvable): Promise<string>;
  199. public resolveInviteCode(data: InviteResolvable): string;
  200. public resolveString(data: StringResolvable): string;
  201. public resolveUser(user: UserResolvable): User;
  202. public resolveUserID(user: UserResolvable): Snowflake;
  203. public static resolveColor(color: ColorResolvable): number;
  204. }
  205. class ClientManager {
  206. constructor(client: Client);
  207. public client: Client;
  208. public heartbeatInterval: number;
  209. public status: number;
  210. public connectToWebSocket(token: string, resolve: Function, reject: Function): void;
  211. }
  212. export class ClientUser extends User {
  213. public blocked: Collection<Snowflake, User>;
  214. public email: string;
  215. public friends: Collection<Snowflake, User>;
  216. public guildSettings: Collection<Snowflake, ClientUserGuildSettings>;
  217. public mfaEnabled: boolean;
  218. public mobile: boolean;
  219. public notes: Collection<Snowflake, string>;
  220. public premium: boolean;
  221. public settings: ClientUserSettings;
  222. public verified: boolean;
  223. public acceptInvite(invite: Invite | string): Promise<Guild>
  224. public addFriend(user?: UserResolvable): Promise<User>;
  225. public createGroupDM(recipients: GroupDMRecipientOptions[]): Promise<GroupDMChannel>;
  226. public createGuild(name: string, region: string, icon?: BufferResolvable | Base64Resolvable): Promise<Guild>;
  227. public fetchMentions(options?: { limit?: number; roles?: boolean, everyone?: boolean; guild?: Guild | Snowflake }): Promise<Message[]>;
  228. public removeFriend(user?: UserResolvable): Promise<User>;
  229. public setActivity(name: string, options?: { url?: string, type?: ActivityType | number }): Promise<ClientUser>;
  230. public setAFK(afk: boolean): Promise<ClientUser>;
  231. public setAvatar(avatar: BufferResolvable | Base64Resolvable): Promise<ClientUser>;
  232. public setEmail(email: string, password: string): Promise<ClientUser>;
  233. public setGame(game: string, streamingURL?: string): Promise<ClientUser>;
  234. public setPassword(newPassword: string, oldPassword: string): Promise<ClientUser>;
  235. public setPresence(data: PresenceData): Promise<ClientUser>;
  236. public setStatus(status: PresenceStatus): Promise<ClientUser>;
  237. public setUsername(username: string, password?: string): Promise<ClientUser>;
  238. }
  239. class ClientUserChannelOverride {
  240. constructor(user: User, data: object);
  241. private patch(data: object): void;
  242. public messageNotifications: GuildChannelMessageNotifications;
  243. public muted: boolean;
  244. }
  245. class ClientUserGuildSettings {
  246. constructor(data: object, guild: Guild);
  247. private patch(data: object): void;
  248. public channelOverrides: Collection<Snowflake, ClientUserChannelOverride>;
  249. public readonly client: Client;
  250. public guildID: Snowflake;
  251. public messageNotifications: GuildChannelMessageNotifications;
  252. public mobilePush: boolean;
  253. public muted: boolean;
  254. public suppressEveryone: boolean;
  255. public update(name: string, value: any): Promise<object>;
  256. }
  257. export class ClientUserSettings {
  258. constructor(user: User, data: object);
  259. private patch(data: object): void;
  260. public convertEmoticons: boolean;
  261. public defaultGuildsRestricted: boolean;
  262. public detectPlatformAccounts: boolean;
  263. public developerMode: boolean;
  264. public enableTTSCommand: boolean;
  265. public explicitContentFilter: 'DISABLED' | 'NON_FRIENDS' | 'FRIENDS_AND_NON_FRIENDS' | string;
  266. public friendsSources: { all: boolean, mutualGuilds: boolean, mutualFriends: boolean };
  267. public guildsPositions: Snowflake[];
  268. public inlineAttachmentMedia: boolean;
  269. public inlineEmbedMedia: boolean;
  270. public locale: string;
  271. public messageDisplayCompact: boolean;
  272. public renderReactions: boolean;
  273. public restrictedGuilds: Snowflake[];
  274. public showCurrentGame: boolean;
  275. public status: PresenceStatus;
  276. public theme: string;
  277. public addRestrictedGuild(guild: Guild): Promise<Guild>;
  278. public removeRestrictedGuild(guild: Guild): Promise<Guild>;
  279. public setGuildPosition(guild: Guild, position: number, relative?: boolean): Promise<Guild>;
  280. public update(name: string, value: any): Promise<object>;
  281. }
  282. class ClientVoiceManager {
  283. constructor(client: Client);
  284. public client: Client;
  285. public connections: Collection<Snowflake, VoiceConnection>;
  286. public joinChannel(channel: VoiceChannel): Promise<VoiceConnection>;
  287. }
  288. export class Collection<K, V> extends Map<K, V> {
  289. private _array: V[];
  290. private _keyArray: K[];
  291. public array(): V[];
  292. public clone(): Collection<K, V>;
  293. public concat(...collections: Collection<K, V>[]): Collection<K, V>;
  294. public deleteAll(): Promise<V>[];
  295. public equals(collection: Collection<any, any>): boolean;
  296. public every(fn: (value: V, key: K, collection: Collection<K, V>) => boolean, thisArg?: any): boolean;
  297. public exists(prop: keyof V, value: any): boolean;
  298. public filter(fn: (value: V, key: K, collection: Collection<K, V>) => boolean, thisArg?: any): Collection<K, V>;
  299. public filterArray(fn: (value: V, key: K, collection: Collection<K, V>) => boolean, thisArg?: any): V[];
  300. public find(prop: keyof V, value: any): V;
  301. public find(fn: (value: V, key: K, collection: Collection<K, V>) => boolean): V;
  302. public findAll(prop: keyof V, value: any): V[];
  303. public findKey(prop: keyof V, value: any): K;
  304. public findKey(fn: (value: V, key: K, collection: Collection<K, V>) => boolean): K;
  305. public first(): V;
  306. public first(count: number): V[];
  307. public firstKey(): K;
  308. public firstKey(count: number): K[];
  309. public keyArray(): K[];
  310. public last(): V;
  311. public last(count: number): V[];
  312. public lastKey(): K;
  313. public lastKey(count: number): K[];
  314. public map<T>(fn: (value: V, key: K, collection: Collection<K, V>) => T, thisArg?: any): T[];
  315. public random(): V;
  316. public random(count: number): V[];
  317. public randomKey(): K;
  318. public randomKey(count: number): K[];
  319. public reduce<T>(fn: (accumulator: any, value: V, key: K, collection: Collection<K, V>) => T, initialValue?: any): T;
  320. public some(fn: (value: V, key: K, collection: Collection<K, V>) => boolean, thisArg?: any): boolean;
  321. public sort(compareFunction?: (a: V, b: V, c?: K, d?: K) => number): Collection<K, V>;
  322. }
  323. abstract class Collector<K, V> extends EventEmitter {
  324. constructor(client: Client, filter: CollectorFilter, options?: CollectorOptions);
  325. private _timeout: NodeJS.Timer;
  326. private _handle(...args: any[]): void;
  327. public readonly client: Client;
  328. public collected: Collection<K, V>;
  329. public ended: boolean;
  330. public filter: CollectorFilter;
  331. public readonly next: Promise<V>;
  332. public options: CollectorOptions;
  333. public stop(reason?: string): void;
  334. protected listener: Function;
  335. public abstract cleanup(): void;
  336. public abstract handle(...args: any[]): CollectorHandler<K, V>;
  337. public abstract postCheck(...args: any[]): string | null;
  338. public on(event: 'collect', listener: (element: V, collector: Collector<K, V>) => void): this;
  339. public on(event: 'end', listener: (collected: Collection<K, V>, reason: string) => void): this;
  340. public on(event: string, listener: Function): this;
  341. public once(event: 'collect', listener: (element: V, collector: Collector<K, V>) => void): this;
  342. public once(event: 'end', listener: (collected: Collection<K, V>, reason: string) => void): this;
  343. public once(event: string, listener: Function): this;
  344. }
  345. class DiscordAPIError extends Error {
  346. constructor(error: object);
  347. private static flattenErrors(obj: object, key: string): string[];
  348. public code: number;
  349. public path: string;
  350. }
  351. export class DMChannel extends TextBasedChannel(Channel) {
  352. constructor(client: Client, data: object);
  353. public lastMessageID: Snowflake;
  354. public messages: Collection<Snowflake, Message>;
  355. public recipient: User;
  356. public toString(): string;
  357. }
  358. export class Emoji {
  359. constructor(guild: Guild, data: object);
  360. public animated: boolean;
  361. public readonly client: Client;
  362. public readonly createdAt: Date;
  363. public readonly createdTimestamp: number;
  364. public guild: Guild;
  365. public id: Snowflake;
  366. public readonly identifier: string;
  367. public managed: boolean;
  368. public name: string;
  369. public requiresColons: boolean;
  370. public readonly roles: Collection<Snowflake, Role>;
  371. public readonly url: string;
  372. public addRestrictedRole(role: Role): Promise<Emoji>;
  373. public addRestrictedRoles(roles: Role[]): Promise<Emoji>;
  374. public edit(data: EmojiEditData, reason?: string): Promise<Emoji>;
  375. public equals(other: Emoji | object): boolean;
  376. public removeRestrictedRole(role: Role): Promise<Emoji>;
  377. public removeRestrictedRoles(roles: Role[]): Promise<Emoji>;
  378. public setName(name: string, reason?: string): Promise<Emoji>;
  379. public toString(): string;
  380. }
  381. export class Game {
  382. constructor(data: object);
  383. public name: string;
  384. public readonly streaming: boolean;
  385. public type: number;
  386. public url: string;
  387. public equals(game: Game): boolean;
  388. }
  389. export class GroupDMChannel extends TextBasedChannel(Channel) {
  390. constructor(client: Client, data: object);
  391. public applicationID: string;
  392. public icon: string;
  393. public lastMessageID: string;
  394. public managed: boolean;
  395. public messages: Collection<Snowflake, Message>;
  396. public name: string;
  397. public nicks: Collection<Snowflake, string>;
  398. public readonly owner: User;
  399. public ownerID: string;
  400. public recipients: Collection<Snowflake, User>;
  401. public addUser(accessTokenOrID: UserResolvable | string, nick?: string): Promise<GroupDMChannel>
  402. public equals(channel: GroupDMChannel): boolean;
  403. public setIcon(icon: Base64Resolvable | BufferResolvable): Promise<GroupDMChannel>;
  404. public toString(): string;
  405. }
  406. export class Guild {
  407. constructor(client: Client, data: object);
  408. private readonly _sortedRoles: Collection<Snowflake, Role>;
  409. private _sortedChannels(type: string): Collection<Snowflake, GuildChannel>
  410. private _sortPositionWithID(collection: Collection<any, any>): Collection<any, any>;
  411. protected setup(data: any): void;
  412. public readonly afkChannel: VoiceChannel;
  413. public afkChannelID: string;
  414. public afkTimeout: number;
  415. public applicationID: string;
  416. public available: boolean;
  417. public channels: Collection<Snowflake, GuildChannel>;
  418. public readonly client: Client;
  419. public readonly createdAt: Date;
  420. public readonly createdTimestamp: number;
  421. public readonly defaultChannel: TextChannel;
  422. public readonly defaultRole: Role;
  423. public embedEnabled: boolean;
  424. public emojis: Collection<Snowflake, Emoji>;
  425. public explicitContentFilter: number;
  426. public features: string[];
  427. public icon: string;
  428. public readonly iconURL: string;
  429. public id: Snowflake;
  430. public readonly joinedAt: Date;
  431. public joinedTimestamp: number;
  432. public large: boolean;
  433. public readonly me: GuildMember;
  434. public memberCount: number;
  435. public members: Collection<Snowflake, GuildMember>;
  436. public readonly messageNotifications: MessageNotifications;
  437. public readonly mobilePush: boolean;
  438. public readonly muted: boolean;
  439. public name: string;
  440. public readonly nameAcronym: string;
  441. public readonly owner: GuildMember;
  442. public ownerID: string;
  443. public readonly position: number;
  444. public presences: Collection<Snowflake, Presence>;
  445. public region: string;
  446. public roles: Collection<Snowflake, Role>;
  447. public splash: string;
  448. public readonly splashURL: string;
  449. public readonly suppressEveryone: boolean;
  450. public readonly systemChannel: GuildChannel;
  451. public systemChannelID: Snowflake;
  452. public verificationLevel: number;
  453. public readonly voiceConnection: VoiceConnection;
  454. public acknowledge(): Promise<Guild>;
  455. public addMember(user: UserResolvable, options: AddGuildMemberOptions): Promise<GuildMember>;
  456. public allowDMs(allow: boolean): Promise<Guild>;
  457. public ban(user: UserResolvable, options?: BanOptions | number | string): Promise<GuildMember | User | string>;
  458. public createChannel(name: string, type?: 'category' | 'text' | 'voice', overwrites?: PermissionOverwrites[] | object[], reason?: string): Promise<CategoryChannel | TextChannel | VoiceChannel>;
  459. public createEmoji(attachment: BufferResolvable | Base64Resolvable, name: string, roles?: Collection<Snowflake, Role> | Role[], reason?: string): Promise<Emoji>;
  460. public createRole(data?: RoleData, reason?: string): Promise<Role>;
  461. public delete(): Promise<Guild>;
  462. public deleteEmoji(emoji: Emoji | string, reason?: string): Promise<void>;
  463. public edit(data: GuildEditData, reason?: string): Promise<Guild>;
  464. public equals(guild: Guild): boolean;
  465. public fetchAuditLogs(options?: GuildAuditLogsFetchOptions): Promise<GuildAuditLogs>;
  466. public fetchBans(): Promise<Collection<Snowflake, User>>;
  467. public fetchInvites(): Promise<Collection<Snowflake, Invite>>;
  468. public fetchMember(user: UserResolvable, cache?: boolean): Promise<GuildMember>;
  469. public fetchMembers(query?: string, limit?: number): Promise<Guild>;
  470. public fetchVoiceRegions(): Promise<Collection<string, VoiceRegion>>;
  471. public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
  472. public leave(): Promise<Guild>;
  473. public member(user: UserResolvable): GuildMember;
  474. public pruneMembers(days: number, dry?: boolean, reason?: string): Promise<number>;
  475. public search(options?: MessageSearchOptions): Promise<MessageSearchResult>;
  476. public setAFKChannel(afkChannel: ChannelResolvable, reason?: string): Promise<Guild>;
  477. public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>;
  478. public setChannelPosition(channel: string | GuildChannel, position: number, relative?: boolean): Promise<Guild>;
  479. public setChannelPositions(channelPositions: ChannelPosition[]): Promise<Guild>;
  480. public setExcplicitContentFilter(explicitContentFilter: number, reason?: string): Promise<Guild>;
  481. public setIcon(icon: Base64Resolvable, reason?: string): Promise<Guild>;
  482. public setName(name: string, reason?: string): Promise<Guild>;
  483. public setOwner(owner: GuildMemberResolvable, reason?: string): Promise<Guild>;
  484. public setPosition(position: number, relative?: boolean): Promise<Guild>;
  485. public setRegion(region: string, reason?: string): Promise<Guild>;
  486. public setRolePosition(role: string | Role, position: number, relative?: boolean): Promise<Guild>;
  487. public setSplash(splash: Base64Resolvable, reason?: string): Promise<Guild>;
  488. public setSystemChannel(systemChannel: ChannelResolvable, reason?: string): Promise<Guild>;
  489. public setVerificationLevel(verificationLevel: number, reason?: string): Promise<Guild>;
  490. public sync(): void;
  491. public toString(): string;
  492. public unban(user: UserResolvable, reason?: string): Promise<User>;
  493. }
  494. export class GuildAuditLogs {
  495. constructor(guild: Guild, data: object);
  496. private webhooks: Collection<Snowflake, Webhook>;
  497. public entries: Collection<Snowflake, GuildAuditLogsEntry>;
  498. public static Actions: GuildAuditLogsActions;
  499. public static Targets: GuildAuditLogsTargets;
  500. public static Entry: typeof GuildAuditLogsEntry;
  501. public static actionType(action: number): GuildAuditLogsActionType;
  502. public static build(...args: any[]): Promise<GuildAuditLogs>;
  503. public static targetType(target: number): GuildAuditLogsTarget;
  504. }
  505. class GuildAuditLogsEntry {
  506. constructor(logs: GuildAuditLogs, guild: Guild, data: object);
  507. public action: GuildAuditLogsAction;
  508. public actionType: GuildAuditLogsActionType;
  509. public changes: AuditLogChange[];
  510. public readonly createdAt: Date;
  511. public readonly createdTimestamp: number;
  512. public executor: User;
  513. public extra: object | Role | GuildMember;
  514. public id: Snowflake;
  515. public reason: string;
  516. public target: Guild | User | Role | Emoji | Invite | Webhook;
  517. public targetType: GuildAuditLogsTarget;
  518. }
  519. export class GuildChannel extends Channel {
  520. constructor(guild: Guild, data: object);
  521. public readonly calculatedPosition: number;
  522. public readonly deletable: boolean;
  523. public guild: Guild;
  524. public readonly messageNotifications: GuildChannelMessageNotifications;
  525. public readonly muted: boolean;
  526. public name: string;
  527. public readonly parent: CategoryChannel;
  528. public parentID: Snowflake;
  529. public permissionOverwrites: Collection<Snowflake, PermissionOverwrites>;
  530. public position: number;
  531. public clone(name?: string, withPermissions?: boolean, withTopic?: boolean, reason?: string): Promise<GuildChannel>;
  532. public createInvite(options?: InviteOptions, reason?: string): Promise<Invite>;
  533. public delete(reason?: string): Promise<GuildChannel>
  534. public edit(data: ChannelData, reason?: string): Promise<GuildChannel>;
  535. public equals(channel: GuildChannel): boolean;
  536. public overwritePermissions(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOptions, reason?: string): Promise<void>;
  537. public permissionsFor(member: GuildMemberResolvable): Permissions;
  538. public setName(name: string, reason?: string): Promise<GuildChannel>;
  539. public setParent(parent: ChannelResolvable, reason?: string): Promise<GuildChannel>
  540. public setPosition(position: number, relative?: boolean): Promise<GuildChannel>;
  541. public setTopic(topic: string, reason?: string): Promise<GuildChannel>;
  542. public toString(): string;
  543. }
  544. export class GuildMember extends PartialTextBasedChannel() {
  545. constructor(guild: Guild, data: object);
  546. public readonly bannable: boolean;
  547. public readonly client: Client;
  548. public readonly colorRole: Role;
  549. public readonly deaf: boolean;
  550. public readonly displayColor: number;
  551. public readonly displayHexColor: string;
  552. public readonly displayName: string;
  553. public guild: Guild;
  554. public readonly highestRole: Role;
  555. public readonly hoistRole: Role;
  556. public readonly id: Snowflake;
  557. public readonly joinedAt: Date;
  558. public joinedTimestamp: number;
  559. public readonly kickable: boolean;
  560. public lastMessageID: string;
  561. public readonly mute: boolean;
  562. public nickname: string;
  563. public readonly permissions: Permissions;
  564. public readonly presence: Presence;
  565. public readonly roles: Collection<Snowflake, Role>;
  566. public selfDeaf: boolean;
  567. public selfMute: boolean;
  568. public serverDeaf: boolean;
  569. public serverMute: boolean;
  570. public speaking: boolean;
  571. public user: User;
  572. public readonly voiceChannel: VoiceChannel;
  573. public voiceChannelID: string;
  574. public voiceSessionID: string;
  575. public addRole(role: Role | Snowflake, reason?: string): Promise<GuildMember>;
  576. public addRoles(roles: Collection<Snowflake, Role> | Role[] | Snowflake[], reason?: string): Promise<GuildMember>;
  577. public ban(options?: BanOptions | number | string): Promise<GuildMember>;
  578. public createDM(): Promise<DMChannel>;
  579. public deleteDM(): Promise<DMChannel>;
  580. public edit(data: object, reason?: string): Promise<GuildMember>;
  581. public hasPermission(permission: PermissionResolvable | PermissionResolvable[], explicit?: boolean, checkAdmin?: boolean, checkOwner?: boolean): boolean;
  582. public hasPermissions(permission: PermissionResolvable[], explicit?: boolean): boolean;
  583. public kick(reason?: string): Promise<GuildMember>;
  584. public missingPermissions(permissions: PermissionResolvable[], explicit?: boolean): PermissionResolvable[];
  585. public permissionsIn(channel: ChannelResolvable): Permissions;
  586. public removeRole(role: Role | Snowflake, reason?: string): Promise<GuildMember>;
  587. public removeRoles(roles: Collection<Snowflake, Role> | Role[] | Snowflake[], reason?: string): Promise<GuildMember>;
  588. public setDeaf(deaf: boolean, reason?: string): Promise<GuildMember>;
  589. public setMute(mute: boolean, reason?: string): Promise<GuildMember>;
  590. public setNickname(nickname: string, reason?: string): Promise<GuildMember>;
  591. public setRoles(roles: Collection<Snowflake, Role> | Role[] | Snowflake[], reason?: string): Promise<GuildMember>;
  592. public setVoiceChannel(voiceChannel: ChannelResolvable): Promise<GuildMember>;
  593. public toString(): string;
  594. }
  595. export class Invite {
  596. constructor(client: Client, data: object);
  597. public channel: GuildChannel | PartialGuildChannel;
  598. public readonly client: Client;
  599. public code: string;
  600. public readonly createdAt: Date;
  601. public createdTimestamp: number;
  602. public readonly expiresAt: Date;
  603. public readonly expiresTimestamp: number;
  604. public guild: Guild | PartialGuild;
  605. public inviter: User;
  606. public maxAge: number;
  607. public maxUses: number;
  608. public memberCount: number;
  609. public presenceCount: number;
  610. public temporary: boolean;
  611. public textChannelCount: number;
  612. public readonly url: string;
  613. public uses: number;
  614. public voiceChannelCount: number;
  615. public delete(reason?: string): Promise<Invite>;
  616. public toString(): string;
  617. }
  618. export class Message {
  619. constructor(channel: TextChannel | DMChannel | GroupDMChannel, data: object, client: Client);
  620. private _edits: Message[];
  621. private patch(data: object): void;
  622. public attachments: Collection<Snowflake, MessageAttachment>;
  623. public author: User;
  624. public channel: TextChannel | DMChannel | GroupDMChannel;
  625. public readonly cleanContent: string;
  626. public readonly client: Client;
  627. public content: string;
  628. public readonly createdAt: Date;
  629. public createdTimestamp: number;
  630. public readonly deletable: boolean;
  631. public readonly editable: boolean;
  632. public readonly editedAt: Date;
  633. public editedTimestamp: number;
  634. public readonly edits: Message[];
  635. public embeds: MessageEmbed[];
  636. public readonly guild: Guild;
  637. public hit: boolean;
  638. public id: Snowflake;
  639. public member: GuildMember;
  640. public mentions: MessageMentions;
  641. public nonce: string;
  642. public readonly pinnable: boolean;
  643. public pinned: boolean;
  644. public reactions: Collection<Snowflake, MessageReaction>;
  645. public system: boolean;
  646. public tts: boolean;
  647. public type: string;
  648. public webhookID: Snowflake;
  649. public acknowledge(): Promise<Message>;
  650. public awaitReactions(filter: CollectorFilter, options?: AwaitReactionsOptions): Promise<Collection<Snowflake, MessageReaction>>;
  651. public clearReactions(): Promise<Message>;
  652. public createReactionCollector(filter: CollectorFilter, options?: ReactionCollectorOptions): ReactionCollector;
  653. public delete(timeout?: number): Promise<Message>;
  654. public edit(content: StringResolvable, options?: MessageEditOptions | RichEmbed): Promise<Message>;
  655. public editCode(lang: string, content: StringResolvable): Promise<Message>;
  656. public equals(message: Message, rawData: object): boolean;
  657. public fetchWebhook(): Promise<Webhook>;
  658. public isMemberMentioned(member: GuildMember | User): boolean;
  659. public isMentioned(data: GuildChannel | User | Role | Snowflake): boolean;
  660. public pin(): Promise<Message>;
  661. public react(emoji: string | Emoji | ReactionEmoji): Promise<MessageReaction>;
  662. public reply(content?: StringResolvable, options?: MessageOptions): Promise<Message | Message[]>;
  663. public reply(options?: MessageOptions): Promise<Message | Message[]>;
  664. public toString(): string;
  665. public unpin(): Promise<Message>;
  666. }
  667. export class MessageAttachment {
  668. constructor(message: Message, data: object);
  669. public readonly client: Client;
  670. public filename: string;
  671. public filesize: number;
  672. public height: number;
  673. public id: Snowflake;
  674. public message: Message;
  675. public proxyURL: string;
  676. public url: string;
  677. public width: number;
  678. }
  679. export class MessageCollector extends Collector<Snowflake, Message> {
  680. constructor(channel: TextChannel | DMChannel | GroupDMChannel, filter: CollectorFilter, options?: MessageCollectorOptions);
  681. public channel: Channel;
  682. public options: MessageCollectorOptions;
  683. public received: number;
  684. public cleanup(): void;
  685. public handle(message: Message): CollectorHandler<Snowflake, Message>;
  686. public postCheck(): string;
  687. }
  688. export class MessageEmbed {
  689. constructor(message: Message, data: object);
  690. public author: MessageEmbedAuthor;
  691. public readonly client: Client;
  692. public color: number;
  693. public readonly createdAt: Date;
  694. public timestamp: number;
  695. public description: string;
  696. public fields: MessageEmbedField[];
  697. public footer: MessageEmbedFooter;
  698. public readonly hexColor: string;
  699. public image: MessageEmbedImage;
  700. public message: Message;
  701. public provider: MessageEmbedProvider;
  702. public thumbnail: MessageEmbedThumbnail;
  703. public title: string;
  704. public type: string;
  705. public url: string;
  706. public video: MessageEmbedVideo;
  707. }
  708. export class MessageEmbedAuthor {
  709. constructor(embed: MessageEmbed, data: object);
  710. public embed: MessageEmbed;
  711. public iconURL: string;
  712. public name: string;
  713. public url: string;
  714. }
  715. export class MessageEmbedField {
  716. constructor(embed: MessageEmbed, data: object);
  717. public embed: MessageEmbed;
  718. public inline: boolean;
  719. public name: string;
  720. public value: string;
  721. }
  722. export class MessageEmbedFooter {
  723. constructor(embed: MessageEmbed, data: object);
  724. public embed: MessageEmbed;
  725. public iconURL: string;
  726. public proxyIconURL: string;
  727. public text: string;
  728. }
  729. export class MessageEmbedImage {
  730. constructor(embed: MessageEmbed, data: object);
  731. public embed: MessageEmbed;
  732. public height: number;
  733. public proxyURL: string;
  734. public url: string;
  735. public width: number;
  736. }
  737. export class MessageEmbedProvider {
  738. constructor(embed: MessageEmbed, data: object);
  739. public embed: MessageEmbed;
  740. public name: string;
  741. public url: string;
  742. }
  743. export class MessageEmbedThumbnail {
  744. constructor(embed: MessageEmbed, data: object);
  745. public embed: MessageEmbed;
  746. public height: number;
  747. public proxyURL: string;
  748. public url: string;
  749. public width: number;
  750. }
  751. export class MessageEmbedVideo {
  752. constructor(embed: MessageEmbed, data: object);
  753. public embed: MessageEmbed;
  754. public height: number;
  755. public url: string;
  756. public width: number;
  757. }
  758. export class MessageMentions {
  759. private _channels: Collection<Snowflake, GuildChannel>;
  760. private _client: Client;
  761. private _content: Message;
  762. private _guild: Guild;
  763. private _members: Collection<Snowflake, GuildMember>;
  764. public readonly channels: Collection<Snowflake, TextChannel>;
  765. public everyone: boolean;
  766. public readonly members: Collection<Snowflake, GuildMember>;
  767. public roles: Collection<Snowflake, Role>;
  768. public users: Collection<Snowflake, User>;
  769. public static CHANNELS_PATTERN: RegExp;
  770. public static EVERYONE_PATTERN: RegExp;
  771. public static ROLES_PATTERN: RegExp;
  772. public static USERS_PATTERN: RegExp;
  773. }
  774. export class MessageReaction {
  775. constructor(message: Message, emoji: object, count: number, me: boolean);
  776. public count: number;
  777. public readonly emoji: Emoji | ReactionEmoji;
  778. public me: boolean;
  779. public message: Message;
  780. public users: Collection<string, User>;
  781. public fetchUsers(limit?: number, options?: { after?: number; before?: number }): Promise<Collection<Snowflake, User>>;
  782. public remove(user?: UserResolvable): Promise<MessageReaction>;
  783. }
  784. export class OAuth2Application {
  785. constructor(client: Client, data: object);
  786. public bot: object;
  787. public botPublic: boolean;
  788. public botRequireCodeGrant: boolean;
  789. public readonly client: Client;
  790. public readonly createdAt: Date;
  791. public readonly createdTimestamp: number;
  792. public description: string;
  793. public flags: number;
  794. public icon: string;
  795. public iconURL: string;
  796. public id: Snowflake;
  797. public name: string;
  798. public owner: User;
  799. public redirectURIs: string[];
  800. public rpcApplicationState: boolean;
  801. public rpcOrigins: string[];
  802. public secret: string;
  803. public reset(): OAuth2Application;
  804. public toString(): string;
  805. }
  806. export class PartialGuild {
  807. constructor(client: Client, data: object);
  808. public readonly client: Client;
  809. public icon: string;
  810. public id: Snowflake;
  811. public name: string;
  812. public splash: string;
  813. }
  814. export class PartialGuildChannel {
  815. constructor(client: Client, data: object);
  816. public readonly client: Client;
  817. public id: Snowflake;
  818. public name: string;
  819. public type: string;
  820. }
  821. export class PermissionOverwrites {
  822. constructor(guildChannel: GuildChannel, data: object);
  823. public allow: number;
  824. public channel: GuildChannel;
  825. public deny: number;
  826. public id: Snowflake;
  827. public type: string;
  828. public delete(reason?: string): Promise<PermissionOverwrites>;
  829. }
  830. export class Permissions {
  831. constructor(permissions: number | PermissionResolvable[]);
  832. constructor(member: GuildMember, permissions: number | PermissionResolvable[]);
  833. private readonly raw: number;
  834. public bitfield: number;
  835. public member: GuildMember;
  836. public add(...permissions: PermissionResolvable[]): this;
  837. public has(permission: PermissionResolvable | PermissionResolvable[], checkAdmin?: boolean): boolean;
  838. public hasPermission(permission: PermissionResolvable, explicit?: boolean): boolean;
  839. public hasPermissions(permissions: PermissionResolvable[], explicit?: boolean): boolean;
  840. public missing(permissions: PermissionResolvable[], checkAdmin?: boolean): PermissionResolvable[];
  841. public missingPermissions(permissions: PermissionResolvable[], checkAdmin?: boolean): PermissionResolvable[];
  842. public remove(...permissions: PermissionResolvable[]): this;
  843. public serialize(checkAdmin?: boolean): PermissionObject;
  844. public static ALL: number;
  845. public static DEFAULT: number;
  846. public static FLAGS: PermissionFlags;
  847. public static resolve(permission: PermissionResolvable | PermissionResolvable[]): number;
  848. }
  849. export class Presence {
  850. constructor(data: object);
  851. public game: Game;
  852. public status: 'online' | 'offline' | 'idle' | 'dnd';
  853. public equals(presence: Presence): boolean;
  854. }
  855. export class ReactionCollector extends Collector<Snowflake, MessageReaction> {
  856. constructor(message: Message, filter: CollectorFilter, options?: ReactionCollectorOptions);
  857. public message: Message;
  858. public options: ReactionCollectorOptions;
  859. public total: number;
  860. public users: Collection<Snowflake, User>;
  861. public cleanup(): void;
  862. public handle(reaction: MessageReaction): CollectorHandler<Snowflake, MessageReaction>;
  863. public postCheck(reaction: MessageReaction, user: User): string;
  864. }
  865. export class ReactionEmoji {
  866. constructor(reaction: MessageReaction, name: string, id: string);
  867. public id: Snowflake;
  868. public readonly identifier: string;
  869. public name: string;
  870. public reaction: MessageReaction;
  871. public toString(): string;
  872. }
  873. class RequestHandler {
  874. constructor(restManager: object);
  875. public readonly globalLimit: boolean;
  876. public queue: object[];
  877. public restManager: object;
  878. public handle(): void;
  879. public push(request: object): void;
  880. }
  881. export class RichEmbed {
  882. constructor(data?: RichEmbedOptions);
  883. public author?: { name: string; url?: string; icon_url?: string; };
  884. public color?: number;
  885. public description?: string;
  886. public fields?: { name: string; value: string; inline?: boolean; }[];
  887. public file?: Attachment | string | FileOptions;
  888. public footer?: { text?: string; icon_url?: string; };
  889. public image?: { url: string; proxy_url?: string; height?: number; width?: number; };
  890. public thumbnail?: { url: string; height?: number; width?: number; };
  891. public timestamp?: Date;
  892. public title?: string;
  893. public url?: string;
  894. public addBlankField(inline?: boolean): this;
  895. public addField(name: StringResolvable, value: StringResolvable, inline?: boolean): this;
  896. public attachFile(file: Attachment | FileOptions | string): this;
  897. public setAuthor(name: StringResolvable, icon?: string, url?: string): this;
  898. public setColor(color: ColorResolvable): this;
  899. public setDescription(description: StringResolvable): this;
  900. public setFooter(text: StringResolvable, icon?: string): this;
  901. public setImage(url: string): this;
  902. public setThumbnail(url: string): this;
  903. public setTimestamp(timestamp?: Date): this;
  904. public setTitle(title: StringResolvable): this;
  905. public setURL(url: string): this;
  906. }
  907. export class Role {
  908. constructor(guild: Guild, data: object);
  909. public readonly calculatedPosition: number;
  910. public readonly client: Client;
  911. public color: number;
  912. public readonly createdAt: Date;
  913. public readonly createdTimestamp: number;
  914. public readonly editable: boolean;
  915. public guild: Guild;
  916. public readonly hexColor: string;
  917. public hoist: boolean;
  918. public id: Snowflake;
  919. public managed: boolean;
  920. public readonly members: Collection<Snowflake, GuildMember>;
  921. public mentionable: boolean;
  922. public name: string;
  923. public permissions: number;
  924. public position: number;
  925. public comparePositionTo(role: Role): number;
  926. public delete(reason?: string): Promise<Role>;
  927. public edit(data: RoleData, reason?: string): Promise<Role>;
  928. public equals(role: Role): boolean;
  929. public hasPermission(permission: PermissionResolvable | PermissionResolvable[], explicit?: boolean, checkAdmin?: boolean): boolean;
  930. public hasPermissions(permissions: PermissionResolvable[], explicit?: boolean): boolean;
  931. public serialize(): PermissionObject;
  932. public setColor(color: string | number, reason?: string): Promise<Role>;
  933. public setHoist(hoist: boolean, reason?: string): Promise<Role>;
  934. public setMentionable(mentionable: boolean, reason?: string): Promise<Role>;
  935. public setName(name: string, reason?: string): Promise<Role>;
  936. public setPermissions(permissions: PermissionResolvable[], reason?: string): Promise<Role>;
  937. public setPosition(position: number, relative?: boolean): Promise<Role>;
  938. public toString(): string;
  939. public static comparePositions(role1: Role, role2: Role): number;
  940. }
  941. class SecretKey {
  942. constructor(key: Uint8Array);
  943. public key: Uint8Array;
  944. }
  945. class SequentialRequestHandler extends RequestHandler {
  946. constructor(restManager: object, endpoint: string);
  947. public busy: boolean;
  948. public endpoint: string;
  949. public readonly globalLimit: boolean;
  950. public queue: object[];
  951. public restManager: object;
  952. public timeDifference: number;
  953. public execute(item: object): Promise<object | Error>;
  954. public handle(): void;
  955. public push(request: object): void;
  956. }
  957. export class Shard {
  958. constructor(manager: ShardingManager, id: number, args?: string[]);
  959. private _handleMessage(message: any): void;
  960. public env: object;
  961. public id: string;
  962. public manager: ShardingManager;
  963. public process: ChildProcess;
  964. public eval(script: string): Promise<any>;
  965. public fetchClientValue(prop: string): Promise<any>;
  966. public send(message: any): Promise<Shard>;
  967. }
  968. export class ShardClientUtil {
  969. constructor(client: Client);
  970. private _handleMessage(message: any): void;
  971. private _respond(type: string, message: any): void;
  972. public readonly count: number;
  973. public readonly id: number;
  974. public broadcastEval(script: string): Promise<any[]>;
  975. public fetchClientValues(prop: string): Promise<any[]>;
  976. public send(message: any): Promise<void>;
  977. public static singleton(client: Client): ShardClientUtil;
  978. }
  979. export class ShardingManager extends EventEmitter {
  980. constructor(file: string, options?: {
  981. totalShards?: number | 'auto';
  982. respawn?: boolean;
  983. shardArgs?: string[];
  984. token?: string;
  985. });
  986. private _spawn(amount: number, delay: number): Promise<Collection<number, Shard>>;
  987. public file: string;
  988. public respawn: boolean;
  989. public shardArgs: string[];
  990. public shards: Collection<number, Shard>;
  991. public token: string;
  992. public totalShards: number | string;
  993. public broadcast(message: any): Promise<Shard[]>;
  994. public broadcastEval(script: string): Promise<any[]>;
  995. public createShard(id: number): Promise<Shard>;
  996. public fetchClientValues(prop: string): Promise<any[]>;
  997. public spawn(amount?: number, delay?: number): Promise<Collection<number, Shard>>;
  998. public on(event: 'launch', listener: (shard: Shard) => void): this;
  999. public on(event: 'message', listener: (shard: Shard, message: any) => void): this;
  1000. public on(event: string, listener: Function): this;
  1001. public once(event: 'launch', listener: (shard: Shard) => void): this;
  1002. public once(event: 'message', listener: (shard: Shard, message: any) => void): this;
  1003. public once(event: string, listener: Function): this;
  1004. }
  1005. export class SnowflakeUtil {
  1006. public static deconstruct(snowflake: Snowflake): DeconstructedSnowflake;
  1007. public static generate(): Snowflake;
  1008. }
  1009. export class StreamDispatcher extends VolumeInterface {
  1010. constructor(player: AudioPlayer, stream: NodeJS.ReadableStream, streamOptions: StreamOptions);
  1011. public destroyed: boolean;
  1012. public readonly passes: number;
  1013. public paused: boolean;
  1014. public player: AudioPlayer;
  1015. public stream: ReadableStream | VoiceBroadcast;
  1016. public readonly time: number;
  1017. public readonly totalStreamTime: number;
  1018. public end(reason?: string): void;
  1019. public pause(): void;
  1020. public resume(): void;
  1021. public setBitrate(bitrate: number | 'auto'): void;
  1022. }
  1023. export class TextChannel extends TextBasedChannel(GuildChannel) {
  1024. constructor(guild: Guild, data: object);
  1025. public lastMessageID: string;
  1026. public readonly members: Collection<Snowflake, GuildMember>;
  1027. public messages: Collection<Snowflake, Message>;
  1028. public nsfw: boolean;
  1029. public topic: string;
  1030. public createWebhook(name: string, avatar: BufferResolvable, reason?: string): Promise<Webhook>;
  1031. public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
  1032. }
  1033. export class User extends PartialTextBasedChannel() {
  1034. constructor(client: Client, data: object);
  1035. public avatar: string;
  1036. public readonly avatarURL: string;
  1037. public bot: boolean;
  1038. public readonly client: Client;
  1039. public readonly createdAt: Date;
  1040. public readonly createdTimestamp: number;
  1041. public readonly defaultAvatarURL: string;
  1042. public discriminator: string;
  1043. public readonly displayAvatarURL: string;
  1044. public readonly dmChannel: DMChannel;
  1045. public id: Snowflake;
  1046. public lastMessageID: string;
  1047. public readonly note: string;
  1048. public readonly presence: Presence;
  1049. public readonly tag: string;
  1050. public username: string;
  1051. public addFriend(): Promise<User>;
  1052. public block(): Promise<User>;
  1053. public createDM(): Promise<DMChannel>;
  1054. public deleteDM(): Promise<DMChannel>;
  1055. public equals(user: User): boolean;
  1056. public fetchProfile(): Promise<UserProfile>;
  1057. public removeFriend(): Promise<User>;
  1058. public setNote(note: string): Promise<User>;
  1059. public toString(): string;
  1060. public typingDurationIn(channel: ChannelResolvable): number;
  1061. public typingIn(channel: ChannelResolvable): boolean;
  1062. public typingSinceIn(channel: ChannelResolvable): Date;
  1063. public unblock(): Promise<User>;
  1064. }
  1065. export class UserConnection {
  1066. constructor(user: User, data: object);
  1067. public id: string;
  1068. public integrations: object[];
  1069. public name: string;
  1070. public revoked: boolean;
  1071. public type: string;
  1072. public user: User;
  1073. }
  1074. export class UserProfile {
  1075. constructor(user: User, data: object);
  1076. public readonly client: Client;
  1077. public connections: Collection<string, UserConnection>;
  1078. public mutualGuilds: Collection<Snowflake, Guild>;
  1079. public premium: boolean;
  1080. public premiumSince: Date;
  1081. public user: User;
  1082. }
  1083. export class Util {
  1084. public static arraysEqual(a: any[], b: any[]): boolean;
  1085. public static cloneObject(obj: object): object;
  1086. public static convertToBuffer(ab: ArrayBuffer | string): Buffer;
  1087. public static escapeMarkdown(text: string, onlyCodeBlock?: boolean, onlyInlineCode?: boolean): string;
  1088. public static fetchRecommendedShards(token: string, guildsPerShard?: number): Promise<number>;
  1089. public static makeError(obj: { name: string, message: string, stack: string }): Error;
  1090. public static makePlainError(err: Error): object;
  1091. public static mergeDefault(def: object, given: object): object;
  1092. public static moveElementInArray(array: any[], element: any, newIndex: number, offset?: boolean): number;
  1093. public static parseEmoji(text: string): { animated: boolean; name: string; id: string; };
  1094. public static splitMessage(text: string, options?: SplitOptions): string | string[];
  1095. public static str2ab(str: string): ArrayBuffer;
  1096. }
  1097. export class VoiceBroadcast extends EventEmitter {
  1098. constructor(client: Client);
  1099. public readonly client: Client;
  1100. public currentTranscoder: object;
  1101. public readonly dispatchers: StreamDispatcher[];
  1102. public prism: object;
  1103. public destroy(): void;
  1104. public end(): void;
  1105. public pause(): void;
  1106. public playArbitraryInput(input: string, options?: StreamOptions): VoiceBroadcast;
  1107. public playConvertedStream(stream: ReadableStream, options?: StreamOptions): VoiceBroadcast;
  1108. public playFile(file: string, options?: StreamOptions): StreamDispatcher;
  1109. public playOpusStream(stream: ReadableStream, options?: StreamOptions): StreamDispatcher;
  1110. public playStream(stream: ReadableStream, options?: StreamOptions): VoiceBroadcast;
  1111. public resume(): void;
  1112. public on(event: string, listener: Function): this;
  1113. public on(event: 'end', listener: () => void): this;
  1114. public on(event: 'error', listener: (error: Error) => void): this;
  1115. public on(event: 'subscribe', listener: (dispatcher: StreamDispatcher) => void): this;
  1116. public on(event: 'unsubscribe', listener: (dispatcher: StreamDispatcher) => void): this;
  1117. public on(event: 'warn', listener: (warning: string | Error) => void): this;
  1118. public on(event: string, listener: Function): this;
  1119. public once(event: 'end', listener: () => void): this;
  1120. public once(event: 'error', listener: (error: Error) => void): this;
  1121. public once(event: 'subscribe', listener: (dispatcher: StreamDispatcher) => void): this;
  1122. public once(event: 'unsubscribe', listener: (dispatcher: StreamDispatcher) => void): this;
  1123. public once(event: 'warn', listener: (warning: string | Error) => void): this;
  1124. public once(event: string, listener: Function): this;
  1125. }
  1126. export class VoiceChannel extends GuildChannel {
  1127. constructor(guild: Guild, data: object);
  1128. public bitrate: number;
  1129. public readonly connection: VoiceConnection;
  1130. public readonly full: boolean;
  1131. public readonly joinable: boolean;
  1132. public members: Collection<Snowflake, GuildMember>;
  1133. public readonly speakable: boolean;
  1134. public userLimit: number;
  1135. public join(): Promise<VoiceConnection>;
  1136. public leave(): void;
  1137. public setBitrate(bitrate: number, reason?: string): Promise<VoiceChannel>;
  1138. public setUserLimit(userLimit: number, reason?: string): Promise<VoiceChannel>;
  1139. }
  1140. export class VoiceConnection extends EventEmitter {
  1141. constructor(voiceManager: ClientVoiceManager, channel: VoiceChannel);
  1142. private authentication: object;
  1143. private sockets: object;
  1144. private ssrcMap: Map<number, boolean>;
  1145. private authenticate(): void;
  1146. private authenticateFailed(reason: string): void;
  1147. private checkAuthenticated(): void;
  1148. private cleanup(): void;
  1149. private connect(): void;
  1150. private onReady(data: object): void;
  1151. private onSessionDescription(mode: string, secret: string): void;
  1152. private onSpeaking(data: object): void;
  1153. private reconnect(token: string, endpoint: string): void;
  1154. private setSpeaking(value: boolean): void;
  1155. private updateChannel(channel: VoiceChannel): void;
  1156. public channel: VoiceChannel;
  1157. public readonly client: Client;
  1158. public readonly dispatcher: StreamDispatcher;
  1159. public player: AudioPlayer;
  1160. public prism: object;
  1161. public receivers: VoiceReceiver[];
  1162. public speaking: boolean;
  1163. public status: number;
  1164. public voiceManager: ClientVoiceManager;
  1165. public createReceiver(): VoiceReceiver;
  1166. public disconnect(): void;
  1167. public playArbitraryInput(input: string, options?: StreamOptions): StreamDispatcher;
  1168. public playBroadcast(broadcast: VoiceBroadcast, options?: StreamOptions): StreamDispatcher;
  1169. public playConvertedStream(stream: ReadableStream, options?: StreamOptions): StreamDispatcher;
  1170. public playFile(file: string, options?: StreamOptions): StreamDispatcher;
  1171. public playOpusStream(steam: ReadableStream, options?: StreamOptions): StreamDispatcher;
  1172. public playStream(stream: ReadableStream, options?: StreamOptions): StreamDispatcher;
  1173. public sendVoiceStateUpdate(options: object): void;
  1174. public setSessionID(sessionID: string): void;
  1175. public setTokenAndEndpoint(token: string, endpoint: string): void;
  1176. public on(event: 'authenticated', listener: () => void): this;
  1177. public on(event: 'debug', listener: (message: string) => void): this;
  1178. public on(event: 'disconnect', listener: (error: Error) => void): this;
  1179. public on(event: 'error', listener: (error: Error) => void): this;
  1180. public on(event: 'failed', listener: (error: Error) => void): this;
  1181. public on(event: 'newSession', listener: () => void): this;
  1182. public on(event: 'ready', listener: () => void): this;
  1183. public on(event: 'reconnecting', listener: () => void): this;
  1184. public on(event: 'speaking', listener: (user: User, speaking: boolean) => void): this;
  1185. public on(event: 'warn', listener: (warning: string | Error) => void): this;
  1186. public on(event: string, listener: Function): this;
  1187. public once(event: 'authenticated', listener: () => void): this;
  1188. public once(event: 'debug', listener: (message: string) => void): this;
  1189. public once(event: 'disconnect', listener: (error: Error) => void): this;
  1190. public once(event: 'error', listener: (error: Error) => void): this;
  1191. public once(event: 'failed', listener: (error: Error) => void): this;
  1192. public once(event: 'newSession', listener: () => void): this;
  1193. public once(event: 'ready', listener: () => void): this;
  1194. public once(event: 'reconnecting', listener: () => void): this;
  1195. public once(event: 'speaking', listener: (user: User, speaking: boolean) => void): this;
  1196. public once(event: 'warn', listener: (warning: string | Error) => void): this;
  1197. public once(event: string, listener: Function): this;
  1198. }
  1199. class VoiceConnectionUDPClient extends EventEmitter {
  1200. constructor(voiceConnection: VoiceConnection);
  1201. public discordAddress: string;
  1202. public readonly discordPort: number;
  1203. public localAddress: string;
  1204. public localPort: string;
  1205. public socket: any;
  1206. public voiceConnection: VoiceConnection;
  1207. public findEndpointAddress(): Promise<string>;
  1208. public send(packet: object): Promise<object>;
  1209. }
  1210. export class VoiceReceiver extends EventEmitter {
  1211. constructor(connection: VoiceConnection);
  1212. private stoppedSpeaking(user: User): void;
  1213. public destroyed: boolean;
  1214. public voiceConnection: VoiceConnection;
  1215. public createOpusStream(user: UserResolvable): ReadableStream;
  1216. public createPCMStream(user: UserResolvable): ReadableStream;
  1217. public destroy(): void;
  1218. public recreate(): void;
  1219. public on(event: 'opus', listener: (user: User, buffer: Buffer) => void): this;
  1220. public on(event: 'pcm', listener: (user: User, buffer: Buffer) => void): this;
  1221. public on(event: 'warn', listener: (reason: string, message: string) => void): this;
  1222. public on(event: string, listener: Function): this;
  1223. public once(event: 'opus', listener: (user: User, buffer: Buffer) => void): this;
  1224. public once(event: 'pcm', listener: (user: User, buffer: Buffer) => void): this;
  1225. public once(event: 'warn', listener: (reason: string, message: string) => void): this;
  1226. public once(event: string, listener: Function): this;
  1227. }
  1228. export class VoiceRegion {
  1229. constructor(data: object);
  1230. public custom: boolean;
  1231. public deprecated: boolean;
  1232. public id: string;
  1233. public name: string;
  1234. public optimal: boolean;
  1235. public sampleHostname: string;
  1236. public vip: boolean;
  1237. }
  1238. class VoiceWebsocket extends EventEmitter {
  1239. constructor(voiceConnection: VoiceConnection);
  1240. public attempts: number;
  1241. public readonly client: Client;
  1242. public voiceConnection: VoiceConnection;
  1243. public ws: any;
  1244. public clearHeartbeat(): void;
  1245. public connect(): void;
  1246. public onClose(): void;
  1247. public onError(error: Error): void;
  1248. public onMessage(event: any): void;
  1249. public onOpen(): void;
  1250. public onPacket(packet: object): void;
  1251. public reset(): void;
  1252. public send(data: string): Promise<string>;
  1253. public sendHeartbeat(): void;
  1254. public sendPacket(packet: object): Promise<string>;
  1255. public setHeartbeat(interval: number): void;
  1256. public on(event: 'ready', listener: (packet: object) => void): this;
  1257. public on(event: 'sessionDescription', listener: (encryptionMode: string, secretKey: SecretKey) => void): this;
  1258. public on(event: 'speaking', listener: (data: object) => void): this;
  1259. public on(event: 'unknownPacket', listener: (packet: object) => void): this;
  1260. public on(event: 'warn', listener: (warn: string) => void): this;
  1261. public on(event: string, listener: Function): this;
  1262. public once(event: 'ready', listener: (packet: object) => void): this;
  1263. public once(event: 'sessionDescription', listener: (encryptionMode: string, secretKey: SecretKey) => void): this;
  1264. public once(event: 'speaking', listener: (data: object) => void): this;
  1265. public once(event: 'unknownPacket', listener: (packet: object) => void): this;
  1266. public once(event: 'warn', listener: (warn: string) => void): this;
  1267. public once(event: string, listener: Function): this;
  1268. }
  1269. export class VolumeInterface extends EventEmitter {
  1270. constructor(object?: { volume: number })
  1271. public readonly volume: number;
  1272. public readonly volumeDecibels: number;
  1273. public readonly volumeLogarithmic: number;
  1274. public setVolume(volume: number): void;
  1275. public setVolumeDecibels(db: number): void;
  1276. public setVolumeLogarithmic(value: number): void;
  1277. public on(event: 'debug', listener: (information: string) => void): this;
  1278. public on(event: 'end', listener: (reason: string) => void): this;
  1279. public on(event: 'error', listener: (err: Error) => void): this;
  1280. public on(event: 'speaking', listener: (value: boolean) => void): this;
  1281. public on(event: 'start', listener: () => void): this;
  1282. public on(event: 'volumeChange', listener: (oldVolume: number, newVolume: number) => void): this;
  1283. public on(event: string, listener: Function): this;
  1284. public once(event: 'debug', listener: (information: string) => void): this;
  1285. public once(event: 'end', listener: (reason: string) => void): this;
  1286. public once(event: 'error', listener: (err: Error) => void): this;
  1287. public once(event: 'speaking', listener: (value: boolean) => void): this;
  1288. public once(event: 'start', listener: () => void): this;
  1289. public once(event: 'volumeChange', listener: (oldVolume: number, newVolume: number) => void): this;
  1290. public once(event: string, listener: Function): this;
  1291. }
  1292. export class Webhook {
  1293. constructor(client: Client, dataOrID: object | string, token: string);
  1294. public avatar: string;
  1295. public channelID: string;
  1296. public readonly client: Client;
  1297. public guildID: string;
  1298. public id: Snowflake;
  1299. public name: string;
  1300. public owner: User | object;
  1301. public token: string;
  1302. public delete(reason?: string): Promise<void>;
  1303. public edit(name: string, avatar: BufferResolvable): Promise<Webhook>;
  1304. public send(content?: StringResolvable, options?: WebhookMessageOptions | RichEmbed | Attachment): Promise<Message | Message[]>;
  1305. public send(options?: WebhookMessageOptions | RichEmbed | Attachment): Promise<Message | Message[]>;
  1306. public sendCode(lang: string, content: StringResolvable, options?: WebhookMessageOptions): Promise<Message | Message[]>;
  1307. public sendFile(attachment: BufferResolvable, name?: string, content?: StringResolvable, options?: WebhookMessageOptions): Promise<Message>;
  1308. public sendMessage(content?: StringResolvable, options?: WebhookMessageOptions): Promise<Message | Message[]>;
  1309. public sendMessage(options?: WebhookMessageOptions): Promise<Message | Message[]>;
  1310. public sendSlackMessage(body: object): Promise<void>;
  1311. }
  1312. export class WebhookClient extends Webhook {
  1313. constructor(id: string, token: string, options?: ClientOptions);
  1314. private _intervals: Set<NodeJS.Timer>;
  1315. private _timeouts: Set<NodeJS.Timer>;
  1316. private resolver: ClientDataResolver;
  1317. private rest: object;
  1318. public options: ClientOptions;
  1319. public clearInterval(interval: NodeJS.Timer): void;
  1320. public clearTimeout(timeout: NodeJS.Timer): void;
  1321. public destroy(): void;
  1322. public setInterval(fn: Function, delay: number, ...args: any[]): NodeJS.Timer;
  1323. public setTimeout(fn: Function, delay: number, ...args: any[]): NodeJS.Timer;
  1324. }
  1325. //#endregion
  1326. //#region Mixins
  1327. // Model the TextBasedChannel mixin system, allowing application of these fields
  1328. // to the classes that use these methods without having to manually add them
  1329. // to each of those classes
  1330. type Constructable<T> = new (...args: any[]) => T;
  1331. const PartialTextBasedChannel: <T>(Base?: Constructable<T>) => Constructable<T & PartialTextBasedChannelFields>;
  1332. const TextBasedChannel: <T>(Base?: Constructable<T>) => Constructable<T & TextBasedChannelFields>;
  1333. type PartialTextBasedChannelFields = {
  1334. lastMessage: Message;
  1335. acknowledge(): Promise<DMChannel | GroupDMChannel | TextChannel>;
  1336. send(content?: StringResolvable, options?: MessageOptions | RichEmbed | Attachment): Promise<Message | Message[]>;
  1337. send(options?: MessageOptions | RichEmbed | Attachment): Promise<Message | Message[]>;
  1338. sendCode(lang: string, content: StringResolvable, options?: MessageOptions): Promise<Message | Message[]>;
  1339. sendEmbed(embed: RichEmbed | RichEmbedOptions, content?: string, options?: MessageOptions): Promise<Message>;
  1340. sendEmbed(embed: RichEmbed | RichEmbedOptions, options?: MessageOptions): Promise<Message>;
  1341. sendFile(attachment: BufferResolvable, name?: string, content?: StringResolvable, options?: MessageOptions): Promise<Message>;
  1342. sendMessage(content?: string, options?: MessageOptions): Promise<Message | Message[]>;
  1343. sendMessage(options?: MessageOptions): Promise<Message | Message[]>;
  1344. };
  1345. type TextBasedChannelFields = {
  1346. typing: boolean;
  1347. typingCount: number;
  1348. awaitMessages(filter: CollectorFilter, options?: AwaitMessagesOptions): Promise<Collection<string, Message>>;
  1349. bulkDelete(messages: Collection<string, Message> | Message[] | number, filterOld?: boolean): Promise<Collection<string, Message>>;
  1350. createCollector(filter: CollectorFilter, options?: CollectorOptions): MessageCollector;
  1351. createMessageCollector(filter: CollectorFilter, options?: CollectorOptions): MessageCollector;
  1352. fetchMessage(messageID: string): Promise<Message>;
  1353. fetchMessages(options?: ChannelLogsQueryOptions): Promise<Collection<string, Message>>;
  1354. fetchPinnedMessages(): Promise<Collection<string, Message>>;
  1355. search(options?: MessageSearchOptions): Promise<MessageSearchResult>;
  1356. startTyping(count?: number): void;
  1357. stopTyping(force?: boolean): void;
  1358. } & PartialTextBasedChannelFields;
  1359. //#endregion
  1360. //#region Typedefs
  1361. type ActivityType = 'PLAYING'
  1362. | 'STREAMING'
  1363. | 'LISTENING'
  1364. | 'WATCHING';
  1365. type AddGuildMemberOptions = {
  1366. accessToken: String;
  1367. nick?: string;
  1368. roles?: Collection<string, Role> | Role[] | string[];
  1369. mute?: boolean;
  1370. deaf?: boolean;
  1371. }
  1372. type AuditLogChange = {
  1373. key: string;
  1374. old?: any;
  1375. new?: any;
  1376. };
  1377. type AwaitMessagesOptions = MessageCollectorOptions & { errors?: string[] };
  1378. type AwaitReactionsOptions = ReactionCollectorOptions & { errors?: string[] };
  1379. type BanOptions = {
  1380. days?: number;
  1381. reason?: string;
  1382. };
  1383. type Base64Resolvable = Buffer | Base64String;
  1384. type Base64String = string;
  1385. type BufferResolvable = Buffer | string;
  1386. type ChannelData = {
  1387. name?: string;
  1388. position?: number;
  1389. topic?: string;
  1390. bitrate?: number;
  1391. userLimit?: number;
  1392. };
  1393. type ChannelLogsQueryOptions = {
  1394. limit?: number
  1395. before?: Snowflake
  1396. after?: Snowflake
  1397. around?: Snowflake
  1398. };
  1399. type ChannelPosition = {
  1400. channel: ChannelResolvable;
  1401. position: number;
  1402. };
  1403. type ChannelResolvable = Channel | Guild | Message | Snowflake;
  1404. type ClientOptions = {
  1405. apiRequestMethod?: string;
  1406. shardId?: number;
  1407. shardCount?: number;
  1408. messageCacheMaxSize?: number;
  1409. messageCacheLifetime?: number;
  1410. messageSweepInterval?: number;
  1411. fetchAllMembers?: boolean;
  1412. disableEveryone?: boolean;
  1413. sync?: boolean;
  1414. restWsBridgeTimeout?: number;
  1415. restTimeOffset?: number;
  1416. disabledEvents?: WSEventType[];
  1417. ws?: WebSocketOptions;
  1418. http?: HTTPOptions;
  1419. };
  1420. type CollectorHandler<K, V> = { key: K, value: V };
  1421. type CollectorFilter = (...args: any[]) => boolean;
  1422. type CollectorOptions = { time?: number };
  1423. type ColorResolvable = ('DEFAULT'
  1424. | 'AQUA'
  1425. | 'GREEN'
  1426. | 'BLUE'
  1427. | 'PURPLE'
  1428. | 'GOLD'
  1429. | 'ORANGE'
  1430. | 'RED'
  1431. | 'GREY'
  1432. | 'DARKER_GREY'
  1433. | 'NAVY'
  1434. | 'DARK_AQUA'
  1435. | 'DARK_GREEN'
  1436. | 'DARK_BLUE'
  1437. | 'DARK_PURPLE'
  1438. | 'DARK_GOLD'
  1439. | 'DARK_ORANGE'
  1440. | 'DARK_RED'
  1441. | 'DARK_GREY'
  1442. | 'LIGHT_GREY'
  1443. | 'DARK_NAVY'
  1444. | 'RANDOM')
  1445. | [number, number, number]
  1446. | number
  1447. | string;
  1448. type DeconstructedSnowflake = {
  1449. timestamp: number;
  1450. date: Date;
  1451. workerID: number;
  1452. processID: number;
  1453. increment: number;
  1454. binary: string;
  1455. };
  1456. type EmojiEditData = {
  1457. name?: string;
  1458. roles?: Collection<Snowflake, Role> | Role[] | Snowflake[];
  1459. };
  1460. type EmojiIdentifierResolvable = string | Emoji | ReactionEmoji;
  1461. type FileOptions = {
  1462. attachment: BufferResolvable;
  1463. name?: string;
  1464. };
  1465. type GroupDMRecipientOptions = {
  1466. user?: UserResolvable | Snowflake;
  1467. accessToken?: string;
  1468. nick?: string;
  1469. };
  1470. type GuildAuditLogsAction = keyof GuildAuditLogsActions;
  1471. type GuildAuditLogsActions = {
  1472. ALL?: null,
  1473. GUILD_UPDATE?: number,
  1474. CHANNEL_CREATE?: number,
  1475. CHANNEL_UPDATE?: number,
  1476. CHANNEL_DELETE?: number,
  1477. CHANNEL_OVERWRITE_CREATE?: number,
  1478. CHANNEL_OVERWRITE_UPDATE?: number,
  1479. CHANNEL_OVERWRITE_DELETE?: number,
  1480. MEMBER_KICK?: number,
  1481. MEMBER_PRUNE?: number,
  1482. MEMBER_BAN_ADD?: number,
  1483. MEMBER_BAN_REMOVE?: number,
  1484. MEMBER_UPDATE?: number,
  1485. MEMBER_ROLE_UPDATE?: number,
  1486. ROLE_CREATE?: number,
  1487. ROLE_UPDATE?: number,
  1488. ROLE_DELETE?: number,
  1489. INVITE_CREATE?: number,
  1490. INVITE_UPDATE?: number,
  1491. INVITE_DELETE?: number,
  1492. WEBHOOK_CREATE?: number,
  1493. WEBHOOK_UPDATE?: number,
  1494. WEBHOOK_DELETE?: number,
  1495. EMOJI_CREATE?: number,
  1496. EMOJI_UPDATE?: number,
  1497. EMOJI_DELETE?: number,
  1498. MESSAGE_DELETE?: number,
  1499. };
  1500. type GuildAuditLogsActionType = 'CREATE'
  1501. | 'DELETE'
  1502. | 'UPDATE'
  1503. | 'ALL';
  1504. type GuildAuditLogsFetchOptions = {
  1505. before?: Snowflake | GuildAuditLogsEntry;
  1506. after?: Snowflake | GuildAuditLogsEntry;
  1507. limit?: number;
  1508. user?: UserResolvable;
  1509. type?: string | number;
  1510. };
  1511. type GuildAuditLogsTarget = keyof GuildAuditLogsTargets;
  1512. type GuildAuditLogsTargets = {
  1513. ALL?: string;
  1514. GUILD?: string;
  1515. CHANNEL?: string;
  1516. USER?: string;
  1517. ROLE?: string;
  1518. INVITE?: string;
  1519. WEBHOOK?: string;
  1520. EMOJI?: string;
  1521. MESSAGE?: string;
  1522. };
  1523. type GuildChannelMessageNotifications = MessageNotifications
  1524. & 'INHERIT';
  1525. type GuildEditData = {
  1526. name?: string;
  1527. region?: string;
  1528. verificationLevel?: number;
  1529. explicitContentFilter?: number;
  1530. afkChannel?: ChannelResolvable;
  1531. systemChannel?: ChannelResolvable;
  1532. afkTimeout?: number;
  1533. icon?: Base64Resolvable;
  1534. owner?: GuildMemberResolvable;
  1535. splash?: Base64Resolvable;
  1536. };
  1537. type GuildMemberEditData = {
  1538. nick?: string;
  1539. roles?: Collection<Snowflake, Role> | Role[] | Snowflake[];
  1540. mute?: boolean;
  1541. deaf?: boolean;
  1542. channel?: ChannelResolvable;
  1543. };
  1544. type GuildMemberResolvable = GuildMember | User;
  1545. type GuildResolvable = Guild | Snowflake;
  1546. type HTTPOptions = {
  1547. version?: number;
  1548. host?: string;
  1549. cdn?: string;
  1550. };
  1551. type InviteOptions = {
  1552. temporary?: boolean;
  1553. maxAge?: number;
  1554. maxUses?: number;
  1555. unique?: boolean;
  1556. };
  1557. type InviteResolvable = string;
  1558. type MessageCollectorOptions = CollectorOptions & {
  1559. max?: number;
  1560. maxMatches?: number;
  1561. };
  1562. type MessageEditOptions = {
  1563. embed?: RichEmbedOptions;
  1564. code?: string | boolean;
  1565. };
  1566. type MessageNotifications = 'EVERYTHING'
  1567. | 'MENTIONS'
  1568. | 'NOTHING';
  1569. type MessageOptions = {
  1570. tts?: boolean;
  1571. nonce?: string;
  1572. embed?: RichEmbed | RichEmbedOptions,
  1573. disableEveryone?: boolean;
  1574. file?: FileOptions | string;
  1575. files?: FileOptions[] | string[];
  1576. code?: string | boolean;
  1577. split?: boolean | SplitOptions;
  1578. reply?: UserResolvable;
  1579. };
  1580. type MessageSearchOptions = {
  1581. content?: string;
  1582. maxID?: Snowflake;
  1583. minID?: Snowflake;
  1584. has?: 'link'
  1585. | 'embed'
  1586. | 'file'
  1587. | 'video'
  1588. | 'image'
  1589. | 'sound'
  1590. | '-link'
  1591. | '-embed'
  1592. | '-file'
  1593. | '-video'
  1594. | '-image'
  1595. | '-sound';
  1596. channel?: ChannelResolvable;
  1597. author?: UserResolvable;
  1598. authorType?: 'user'
  1599. | 'bot'
  1600. | 'webhook'
  1601. | '-user'
  1602. | '-bot'
  1603. | '-webhook';
  1604. sortBy?: 'relevant' | 'recent';
  1605. sortOrder?: 'asc' | 'desc';
  1606. contextSize?: number;
  1607. limit?: number;
  1608. offset?: number;
  1609. mentions?: UserResolvable;
  1610. mentionsEveryone?: boolean;
  1611. linkHostname?: string;
  1612. embedProvider?: string;
  1613. embedType?: 'image' | 'video' | 'url' | 'rich';
  1614. attachmentFilename?: string;
  1615. attachmentExtension?: string;
  1616. before?: Date;
  1617. after?: Date;
  1618. during?: Date;
  1619. nsfw?: boolean;
  1620. };
  1621. type MessageSearchResult = {
  1622. totalResults: number;
  1623. messages: Message[][];
  1624. }
  1625. type PermissionFlags = {
  1626. ADMINISTRATOR?: number;
  1627. CREATE_INSTANT_INVITE?: number;
  1628. KICK_MEMBERS?: number;
  1629. BAN_MEMBERS?: number;
  1630. MANAGE_CHANNELS?: number;
  1631. MANAGE_GUILD?: number;
  1632. ADD_REACTIONS?: number;
  1633. VIEW_AUDIT_LOG?: number;
  1634. VIEW_CHANNEL?: number;
  1635. READ_MESSAGES?: number;
  1636. SEND_MESSAGES?: number;
  1637. SEND_TTS_MESSAGES?: number;
  1638. MANAGE_MESSAGES?: number;
  1639. EMBED_LINKS?: number;
  1640. ATTACH_FILES?: number;
  1641. READ_MESSAGE_HISTORY?: number;
  1642. MENTION_EVERYONE?: number;
  1643. USE_EXTERNAL_EMOJIS?: number;
  1644. EXTERNAL_EMOJIS?: number;
  1645. CONNECT?: number;
  1646. SPEAK?: number;
  1647. MUTE_MEMBERS?: number;
  1648. DEAFEN_MEMBERS?: number;
  1649. MOVE_MEMBERS?: number;
  1650. USE_VAD?: number;
  1651. CHANGE_NICKNAME?: number;
  1652. MANAGE_NICKNAMES?: number;
  1653. MANAGE_ROLES?: number;
  1654. MANAGE_ROLES_OR_PERMISSIONS?: number;
  1655. MANAGE_WEBHOOKS?: number;
  1656. MANAGE_EMOJIS?: number;
  1657. };
  1658. type PermissionObject = {
  1659. ADMINISTRATOR?: boolean;
  1660. CREATE_INSTANT_INVITE?: boolean;
  1661. KICK_MEMBERS?: boolean;
  1662. BAN_MEMBERS?: boolean;
  1663. MANAGE_CHANNELS?: boolean;
  1664. MANAGE_GUILD?: boolean;
  1665. ADD_REACTIONS?: boolean;
  1666. VIEW_AUDIT_LOG?: boolean;
  1667. VIEW_CHANNEL?: number;
  1668. READ_MESSAGES?: boolean;
  1669. SEND_MESSAGES?: boolean;
  1670. SEND_TTS_MESSAGES?: boolean;
  1671. MANAGE_MESSAGES?: boolean;
  1672. EMBED_LINKS?: boolean;
  1673. ATTACH_FILES?: boolean;
  1674. READ_MESSAGE_HISTORY?: boolean;
  1675. MENTION_EVERYONE?: boolean;
  1676. USE_EXTERNAL_EMOJIS?: boolean;
  1677. EXTERNAL_EMOJIS?: boolean;
  1678. CONNECT?: boolean;
  1679. SPEAK?: boolean;
  1680. MUTE_MEMBERS?: boolean;
  1681. DEAFEN_MEMBERS?: boolean;
  1682. MOVE_MEMBERS?: boolean;
  1683. USE_VAD?: boolean;
  1684. CHANGE_NICKNAME?: boolean;
  1685. MANAGE_NICKNAMES?: boolean;
  1686. MANAGE_ROLES?: boolean;
  1687. MANAGE_ROLES_OR_PERMISSIONS?: boolean;
  1688. MANAGE_WEBHOOKS?: boolean;
  1689. MANAGE_EMOJIS?: boolean;
  1690. };
  1691. type PermissionString = 'ADMINISTRATOR'
  1692. | 'CREATE_INSTANT_INVITE'
  1693. | 'KICK_MEMBERS'
  1694. | 'BAN_MEMBERS'
  1695. | 'MANAGE_CHANNELS'
  1696. | 'MANAGE_GUILD'
  1697. | 'ADD_REACTIONS'
  1698. | 'VIEW_CHANNEL'
  1699. | 'READ_MESSAGES'
  1700. | 'SEND_MESSAGES'
  1701. | 'SEND_TTS_MESSAGES'
  1702. | 'MANAGE_MESSAGES'
  1703. | 'EMBED_LINKS'
  1704. | 'ATTACH_FILES'
  1705. | 'READ_MESSAGE_HISTORY'
  1706. | 'MENTION_EVERYONE'
  1707. | 'USE_EXTERNAL_EMOJIS'
  1708. | 'EXTERNAL_EMOJIS'
  1709. | 'CONNECT'
  1710. | 'SPEAK'
  1711. | 'MUTE_MEMBERS'
  1712. | 'DEAFEN_MEMBERS'
  1713. | 'MOVE_MEMBERS'
  1714. | 'USE_VAD'
  1715. | 'CHANGE_NICKNAME'
  1716. | 'MANAGE_NICKNAMES'
  1717. | 'MANAGE_ROLES'
  1718. | 'MANAGE_ROLES_OR_PERMISSIONS'
  1719. | 'MANAGE_WEBHOOKS'
  1720. | 'MANAGE_EMOJIS';
  1721. type PermissionOverwriteOptions = PermissionObject;
  1722. type PermissionResolvable = PermissionString | number;
  1723. type PresenceData = {
  1724. status?: PresenceStatus;
  1725. afk?: boolean;
  1726. game?: {
  1727. name?: string;
  1728. url?: string;
  1729. }
  1730. }
  1731. type PresenceStatus = 'online' | 'idle' | 'invisible' | 'dnd';
  1732. type ReactionCollectorOptions = CollectorOptions & {
  1733. max?: number;
  1734. maxEmojis?: number;
  1735. maxUsers?: number;
  1736. };
  1737. type RichEmbedOptions = {
  1738. title?: string;
  1739. description?: string;
  1740. url?: string;
  1741. timestamp?: Date;
  1742. color?: number | string;
  1743. fields?: { name: string; value: string; inline?: boolean; }[];
  1744. file?: Attachment| string | FileOptions;
  1745. author?: { name: string; url?: string; icon_url?: string; };
  1746. thumbnail?: { url: string; height?: number; width?: number; };
  1747. image?: { url: string; proxy_url?: string; height?: number; width?: number; };
  1748. video?: { url: string; height: number; width: number; };
  1749. footer?: { text?: string; icon_url?: string; };
  1750. };
  1751. type RoleData = {
  1752. name?: string;
  1753. color?: ColorResolvable;
  1754. hoist?: boolean;
  1755. position?: number;
  1756. permissions?: PermissionString[];
  1757. mentionable?: boolean;
  1758. };
  1759. type RoleResolvable = Role | string;
  1760. type Snowflake = string;
  1761. type SplitOptions = {
  1762. maxLength?: number;
  1763. char?: string;
  1764. prepend?: string;
  1765. append?: string;
  1766. };
  1767. type Status = number;
  1768. type StreamOptions = {
  1769. seek?: number;
  1770. volume?: number;
  1771. passes?: number;
  1772. bitrate?: number | 'auto';
  1773. };
  1774. type StringResolvable = string | string[] | any;
  1775. type UserResolvable = User | Snowflake | Message | Guild | GuildMember;
  1776. type VoiceStatus = number;
  1777. type WebhookMessageOptions = {
  1778. username?: string;
  1779. avatarURL?: string;
  1780. tts?: boolean;
  1781. nonce?: string;
  1782. embeds?: (RichEmbed | object)[];
  1783. disableEveryone?: boolean;
  1784. file?: FileOptions | BufferResolvable | Attachment;
  1785. files?: (FileOptions | BufferResolvable | Attachment)[];
  1786. code?: string | boolean;
  1787. split?: boolean | SplitOptions;
  1788. };
  1789. type WebSocketOptions = {
  1790. large_threshold?: number;
  1791. compress?: boolean;
  1792. };
  1793. type WSEventType = 'READY'
  1794. | 'RESUMED'
  1795. | 'GUILD_SYNC'
  1796. | 'GUILD_CREATE'
  1797. | 'GUILD_DELETE'
  1798. | 'GUILD_UPDATE'
  1799. | 'GUILD_MEMBER_ADD'
  1800. | 'GUILD_MEMBER_REMOVE'
  1801. | 'GUILD_MEMBER_UPDATE'
  1802. | 'GUILD_MEMBERS_CHUNK'
  1803. | 'GUILD_ROLE_CREATE'
  1804. | 'GUILD_ROLE_DELETE'
  1805. | 'GUILD_ROLE_UPDATE'
  1806. | 'GUILD_BAN_ADD'
  1807. | 'GUILD_BAN_REMOVE'
  1808. | 'CHANNEL_CREATE'
  1809. | 'CHANNEL_DELETE'
  1810. | 'CHANNEL_UPDATE'
  1811. | 'CHANNEL_PINS_UPDATE'
  1812. | 'MESSAGE_CREATE'
  1813. | 'MESSAGE_DELETE'
  1814. | 'MESSAGE_UPDATE'
  1815. | 'MESSAGE_DELETE_BULK'
  1816. | 'MESSAGE_REACTION_ADD'
  1817. | 'MESSAGE_REACTION_REMOVE'
  1818. | 'MESSAGE_REACTION_REMOVE_ALL'
  1819. | 'USER_UPDATE'
  1820. | 'USER_NOTE_UPDATE'
  1821. | 'USER_SETTINGS_UPDATE'
  1822. | 'USER_GUILD_SETTINGS_UPDATE'
  1823. | 'PRESENCE_UPDATE'
  1824. | 'VOICE_STATE_UPDATE'
  1825. | 'TYPING_START'
  1826. | 'VOICE_SERVER_UPDATE'
  1827. | 'RELATIONSHIP_ADD'
  1828. | 'RELATIONSHIP_REMOVE';
  1829. //#endregion
  1830. }