diff --git a/examples/applicationCommands.js b/examples/applicationCommands.js index 38c22bccb..dca23c2c0 100644 --- a/examples/applicationCommands.js +++ b/examples/applicationCommands.js @@ -4,7 +4,9 @@ const Constants = Dysnomia.Constants; // Replace TOKEN with your bot account's token const bot = new Dysnomia("BOT TOKEN", { - intents: [] //No intents are needed for interactions, but you still need to specify either an empty array or 0 + gateway: { + intents: [] //No intents are needed for interactions, but you still need to specify either an empty array or 0 + } }); bot.on("ready", async () => { // When the bot is ready diff --git a/examples/components.js b/examples/components.js index e89243959..0007daa54 100644 --- a/examples/components.js +++ b/examples/components.js @@ -4,7 +4,9 @@ const Constants = Dysnomia.Constants; // Replace TOKEN with your bot account's token const bot = new Dysnomia("BOT TOKEN", { - intents: ["guildMessages"] + gateway: { + intents: ["guildMessages"] + } }); bot.on("ready", async () => { // When the bot is ready diff --git a/examples/intent.js b/examples/intent.js index 1de5e354b..3f5519bea 100644 --- a/examples/intent.js +++ b/examples/intent.js @@ -2,10 +2,12 @@ const Dysnomia = require("@projectdysnomai/dysnomia"); // Replace TOKEN with your bot account's token const bot = new Dysnomia("Bot TOKEN", { - intents: [ - "guilds", - "guildMessages" - ] + gateway: { + intents: [ + "guilds", + "guildMessages" + ] + } }); bot.on("ready", () => { // When the bot is ready diff --git a/examples/sharding.js b/examples/sharding.js index 7201d480d..a298176d4 100644 --- a/examples/sharding.js +++ b/examples/sharding.js @@ -2,11 +2,13 @@ const Dysnomia = require("@projectdysnomia/dysnomia"); // Replace TOKEN with your bot account's token const bot = new Dysnomia("Bot TOKEN", { - firstShardID: 0, - lastShardID: 15, - maxShards: 16, - getAllUsers: false, - intents: ["guilds", "guildMembers", "guildPresences"] + gateway: { + firstShardID: 0, + lastShardID: 15, + maxShards: 16, + getAllUsers: false, + intents: ["guilds", "guildMembers", "guildPresences"] + } }); bot.on("ready", () => { // When the bot is ready diff --git a/index.d.ts b/index.d.ts index 88e245b96..299eb3e3d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -78,9 +78,9 @@ declare namespace Dysnomia { type ChannelTypes = GuildChannelTypes | PrivateChannelTypes; type GuildChannelTypes = Exclude; type TextChannelTypes = GuildTextChannelTypes | PrivateChannelTypes; - type GuildTextChannelTypes = Constants["ChannelTypes"][keyof Pick]; - type GuildThreadChannelTypes = Constants["ChannelTypes"][keyof Pick]; - type GuildPublicThreadChannelTypes = Exclude; + type GuildTextChannelTypes = Constants["ChannelTypes"][keyof Pick]; + type GuildThreadChannelTypes = Constants["ChannelTypes"][keyof Pick]; + type GuildPublicThreadChannelTypes = Exclude; type GuildVoiceChannelTypes = Constants["ChannelTypes"][keyof Pick]; type PrivateChannelTypes = Constants["ChannelTypes"][keyof Pick]; type TextVoiceChannelTypes = Constants["ChannelTypes"][keyof Pick]; @@ -409,16 +409,11 @@ declare namespace Dysnomia { editMessage(messageID: string, content: MessageContentEdit): Promise>; getMessage(messageID: string): Promise>; getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; - /** @deprecated */ - getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; getMessages(options?: GetMessagesOptions): Promise[]>; - /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise; removeMessageReaction(messageID: string, reaction: string, userID?: string): Promise; sendTyping(): Promise; unsendMessage(messageID: string): Promise; } - // @ts-ignore ts(2430) - ThreadTextable can't properly extend Textable because of getMessageReaction deprecated overload interface ThreadTextable extends Textable, Pinnable { lastPinTimestamp?: number; deleteMessages(messageIDs: string[], reason?: string): Promise; @@ -436,51 +431,15 @@ declare namespace Dysnomia { // Client interface ClientOptions { - /** @deprecated */ - agent?: HTTPSAgent; allowedMentions?: AllowedMentions; - /** @deprecated */ - autoreconnect?: boolean; - /** @deprecated */ - compress?: boolean; - /** @deprecated */ - connectionTimeout?: number; defaultImageFormat?: string; defaultImageSize?: number; - /** @deprecated */ - disableEvents?: Record; - /** @deprecated */ - firstShardID?: number; gateway?: GatewayOptions; - /** @deprecated */ - getAllUsers?: boolean; - /** @deprecated */ - guildCreateTimeout?: number; - /** @deprecated */ - intents?: number | (IntentStrings | number)[]; - /** @deprecated */ - largeThreshold?: number; - /** @deprecated */ - lastShardID?: number; - /** @deprecated */ - latencyThreshold?: number; - /** @deprecated */ - maxReconnectAttempts?: number; - /** @deprecated */ - maxResumeAttempts?: number; - /** @deprecated */ - maxShards?: number | "auto"; messageLimit?: number; opusOnly?: boolean; - /** @deprecated */ - ratelimiterOffset?: number; - /** @deprecated */ - reconnectDelay?: ReconnectDelayFunction; requestTimeout?: number; rest?: RequestHandlerOptions; restMode?: boolean; - /** @deprecated */ - seedVoiceConnections?: boolean; ws?: unknown; } interface CommandClientOptions { @@ -497,7 +456,6 @@ declare namespace Dysnomia { interface RequestHandlerOptions { agent?: HTTPSAgent; baseURL?: string; - decodeReasons?: boolean; disableLatencyCompensation?: boolean; domain?: string; https?: boolean; @@ -668,8 +626,6 @@ declare namespace Dysnomia { maxVideoChannelUsers?: number; mfaLevel: MFALevel; name: string; - /** @deprecated */ - nsfw: boolean; nsfwLevel: NSFWLevel; ownerID: string; preferredLocale?: string; @@ -933,8 +889,6 @@ declare namespace Dysnomia { // Guild export interface BanMemberOptions { - /** @deprecated */ - deleteMessageDays?: number; deleteMessageSeconds?: number; reason?: string; } @@ -1344,8 +1298,6 @@ declare namespace Dysnomia { embeds?: EmbedOptions[]; flags?: number; messageReference?: MessageReferenceReply; - /** @deprecated */ - messageReferenceID?: string; stickerIDs?: string[]; tts?: boolean; } @@ -1401,8 +1353,6 @@ declare namespace Dysnomia { } interface GetMessageReactionOptions { after?: string; - /** @deprecated */ - before?: string; limit?: number; } @@ -1864,7 +1814,7 @@ declare namespace Dysnomia { AUTO_MODERATION_RULE_UPDATE: 141; AUTO_MODERATION_RULE_DELETE: 142; AUTO_MODERATION_BLOCK_MESSAGE: 143; - + CREATOR_MONETIZATION_REQUEST_CREATED: 150; CREATOR_MONETIZATION_TERMS_ACCEPTED: 151; @@ -1907,14 +1857,20 @@ declare namespace Dysnomia { GUILD_VOICE: 2; GROUP_DM: 3; GUILD_CATEGORY: 4; + GUILD_ANNOUNCEMENT: 5; + /** @deprecated */ GUILD_NEWS: 5; + ANNOUNCEMENT_THREAD: 10; + /** @deprecated */ GUILD_NEWS_THREAD: 10; + PUBLIC_THREAD: 11; + /** @deprecated */ GUILD_PUBLIC_THREAD: 11; + PRIVATE_THREAD: 12; + /** @deprecated */ GUILD_PRIVATE_THREAD: 12; GUILD_STAGE_VOICE: 13; - /** @deprecated */ - GUILD_STAGE: 13; }; ComponentTypes: { ACTION_ROW: 1; @@ -1937,20 +1893,14 @@ declare namespace Dysnomia { }; GatewayOPCodes: { DISPATCH: 0; - /** @deprecated */ - EVENT: 0; HEARTBEAT: 1; IDENTIFY: 2; PRESENCE_UPDATE: 3; - /** @deprecated */ - STATUS_UPDATE: 3; VOICE_STATE_UPDATE: 4; VOICE_SERVER_PING: 5; RESUME: 6; RECONNECT: 7; REQUEST_GUILD_MEMBERS: 8; - /** @deprecated */ - GET_GUILD_MEMBERS: 8; INVALID_SESSION: 9; HELLO: 10; HEARTBEAT_ACK: 11; @@ -2035,8 +1985,6 @@ declare namespace Dysnomia { guildMembers: 2; guildBans: 4; guildEmojisAndStickers: 8; - /** @deprecated */ - guildEmojis: 8; guildIntegrations: 16; guildWebhooks: 32; guildInvites: 64; @@ -2143,15 +2091,9 @@ declare namespace Dysnomia { manageGuild: 32n; addReactions: 64n; viewAuditLog: 128n; - /** @deprecated */ - viewAuditLogs: 128n; voicePrioritySpeaker: 256n; voiceStream: 512n; - /** @deprecated */ - stream: 512n; viewChannel: 1024n; - /** @deprecated */ - readMessages: 1024n; sendMessages: 2048n; sendTTSMessages: 4096n; manageMessages: 8192n; @@ -2160,8 +2102,6 @@ declare namespace Dysnomia { readMessageHistory: 65536n; mentionEveryone: 131072n; useExternalEmojis: 262144n; - /** @deprecated */ - externalEmojis: 262144n; viewGuildInsights: 524288n; voiceConnect: 1048576n; voiceSpeak: 2097152n; @@ -2174,11 +2114,7 @@ declare namespace Dysnomia { manageRoles: 268435456n; manageWebhooks: 536870912n; manageEmojisAndStickers: 1073741824n; - /** @deprecated */ - manageEmojis: 1073741824n; useApplicationCommands: 2147483648n; - /** @deprecated */ - useSlashCommands: 2147483648n; voiceRequestToSpeak: 4294967296n; manageEvents: 8589934592n; manageThreads: 17179869184n; @@ -2256,32 +2192,44 @@ declare namespace Dysnomia { }; UserFlags: { NONE: 0; + STAFF: 1; + /** @deprecated */ DISCORD_STAFF: 1; + /** @deprecated */ DISCORD_EMPLOYEE: 1; PARTNER: 2; PARTNERED_SERVER_OWNER: 2; /** @deprecated */ DISCORD_PARTNER: 2; HYPESQUAD: 4; + /** @deprecated */ HYPESQUAD_EVENTS: 4; BUG_HUNTER_LEVEL_1: 8; HYPESQUAD_ONLINE_HOUSE_1: 64; + /** @deprecated */ HOUSE_BRAVERY: 64; HYPESQUAD_ONLINE_HOUSE_2: 128; + /** @deprecated */ HOUSE_BRILLIANCE: 128; HYPESQUAD_ONLINE_HOUSE_3: 256; + /** @deprecated */ HOUSE_BALANCE: 256; PREMIUM_EARLY_SUPPORTER: 512; + /** @deprecated */ EARLY_SUPPORTER: 512; TEAM_PSEUDO_USER: 1024; + /** @deprecated */ TEAM_USER: 1024; SYSTEM: 4096; BUG_HUNTER_LEVEL_2: 16384; VERIFIED_BOT: 65536; VERIFIED_DEVELOPER: 131072; + /** @deprecated */ VERIFIED_BOT_DEVELOPER: 131072; + /** @deprecated */ EARLY_VERIFIED_BOT_DEVELOPER: 131072; CERTIFIED_MODERATOR: 262144; + /** @deprecated */ DISCORD_CERTIFIED_MODERATOR: 262144; BOT_HTTP_INTERACTIONS: 524288; SPAMMER: 1048576; @@ -2309,8 +2257,6 @@ declare namespace Dysnomia { HELLO: 8; RESUMED: 9; CLIENT_DISCONNECT: 13; - /** @deprecated */ - DISCONNECT: 13; }; GuildScheduledEventStatus: { SCHEDULED: 1; @@ -2448,8 +2394,6 @@ declare namespace Dysnomia { addGuildMemberRole(guildID: string, memberID: string, roleID: string, reason?: string): Promise; addMessageReaction(channelID: string, messageID: string, reaction: string): Promise; banGuildMember(guildID: string, userID: string, options?: BanMemberOptions): Promise; - /** @deprecated */ - banGuildMember(guildID: string, userID: string, deleteMessageDays?: number, reason?: string): Promise; bulkEditCommands(commands: ApplicationCommandStructure[]): Promise[]>; bulkEditGuildCommands(guildID: string, commands: ApplicationCommandStructure[]): Promise[]>; closeVoiceConnection(guildID: string): void; @@ -2477,7 +2421,7 @@ declare namespace Dysnomia { createChannel( guildID: string, name: string, - type: Constants["ChannelTypes"]["GUILD_NEWS"], + type: Constants["ChannelTypes"]["GUILD_ANNOUNCEMENT"], options?: CreateChannelOptions ): Promise; createChannel( @@ -2492,54 +2436,6 @@ declare namespace Dysnomia { type?: number, options?: CreateChannelOptions ): Promise; - /** @deprecated */ - createChannel( - guildID: string, - name: string, - type: Constants["ChannelTypes"]["GUILD_TEXT"], - reason?: string, - options?: CreateChannelOptions | string - ): Promise; - /** @deprecated */ - createChannel( - guildID: string, - name: string, - type: Constants["ChannelTypes"]["GUILD_VOICE"], - reason?: string, - options?: CreateChannelOptions | string - ): Promise; - /** @deprecated */ - createChannel( - guildID: string, - name: string, - type: Constants["ChannelTypes"]["GUILD_CATEGORY"], - reason?: string, - options?: CreateChannelOptions | string - ): Promise; - /** @deprecated */ - createChannel( - guildID: string, - name: string, - type: Constants["ChannelTypes"]["GUILD_NEWS"], - reason?: string, - options?: CreateChannelOptions | string - ): Promise; - /** @deprecated */ - createChannel( - guildID: string, - name: string, - type: Constants["ChannelTypes"]["GUILD_STAGE_VOICE"], - reason?: string, - options?: CreateChannelOptions | string - ): Promise; - /** @deprecated */ - createChannel( - guildID: string, - name: string, - type?: number, - reason?: string, - options?: CreateChannelOptions | string - ): Promise; createChannelInvite( channelID: string, options?: CreateChannelInviteOptions, @@ -2624,8 +2520,6 @@ declare namespace Dysnomia { editGuildWelcomeScreen(guildID: string, options: WelcomeScreenOptions): Promise; editGuildWidget(guildID: string, options: Widget): Promise; editMessage(channelID: string, messageID: string, content: MessageContentEdit): Promise; - /** @deprecated */ - editNickname(guildID: string, nick: string, reason?: string): Promise; editRole(guildID: string, roleID: string, options: RoleOptions, reason?: string): Promise; // TODO not all options are available? editRolePosition(guildID: string, roleID: string, position: number): Promise; editSelf(options: EditSelfOptions): Promise; @@ -2668,16 +2562,12 @@ declare namespace Dysnomia { getEmojiGuild(emojiID: string): Promise; getGateway(): Promise<{ url: string }>; getGuildAuditLog(guildID: string, options?: GetGuildAuditLogOptions): Promise; - /** @deprecated */ - getGuildAuditLogs(guildID: string, limit?: number, before?: string, actionType?: number, userID?: string): Promise; getGuildBan(guildID: string, userID: string): Promise; getGuildBans(guildID: string, options?: GetGuildBansOptions): Promise; getGuildCommand = AnyApplicationCommand>(guildID: string, commandID: string, withLocalizations?: W): Promise; getGuildCommandPermissions(guildID: string): Promise; getGuildCommands(guildID: string, withLocalizations?: W): Promise[]>; getGuildDiscovery(guildID: string): Promise; - /** @deprecated */ - getGuildEmbed(guildID: string): Promise; getGuildIntegrations(guildID: string): Promise; getGuildInvites(guildID: string): Promise; getGuildPreview(guildID: string): Promise; @@ -2694,11 +2584,7 @@ declare namespace Dysnomia { getJoinedPrivateArchivedThreads(channelID: string, options?: GetArchivedThreadsOptions): Promise>; getMessage(channelID: string, messageID: string): Promise; getMessageReaction(channelID: string, messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; - /** @deprecated */ - getMessageReaction(channelID: string, messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; getMessages(channelID: string, options?: GetMessagesOptions): Promise; - /** @deprecated */ - getMessages(channelID: string, limit?: number, before?: string, after?: string, around?: string): Promise; getNitroStickerPacks(): Promise<{ sticker_packs: StickerPack[] }>; getOAuthApplication(): Promise; getPins(channelID: string): Promise; @@ -2710,12 +2596,8 @@ declare namespace Dysnomia { getRESTGuildEmojis(guildID: string): Promise; getRESTGuildMember(guildID: string, memberID: string): Promise; getRESTGuildMembers(guildID: string, options?: GetRESTGuildMembersOptions): Promise; - /** @deprecated */ - getRESTGuildMembers(guildID: string, limit?: number, after?: string): Promise; getRESTGuildRoles(guildID: string): Promise; getRESTGuilds(options?: GetRESTGuildsOptions): Promise; - /** @deprecated */ - getRESTGuilds(limit?: number, before?: string, after?: string): Promise; getRESTGuildScheduledEvent(guildID: string, eventID: string, options?: GetGuildScheduledEventOptions): Promise; getRESTGuildSticker(guildID: string, stickerID: string): Promise; getRESTGuildStickers(guildID: string): Promise; @@ -2740,15 +2622,6 @@ declare namespace Dysnomia { pinMessage(channelID: string, messageID: string): Promise; pruneMembers(guildID: string, options?: PruneMemberOptions): Promise; purgeChannel(channelID: string, options: PurgeChannelOptions): Promise; - /** @deprecated */ - purgeChannel( - channelID: string, - limit?: number, - filter?: (m: Message) => boolean, - before?: string, - after?: string, - reason?: string - ): Promise; removeGuildMemberRole(guildID: string, memberID: string, roleID: string, reason?: string): Promise; removeMessageReaction(channelID: string, messageID: string, reaction: string, userID?: string): Promise; removeMessageReactionEmoji(channelID: string, messageID: string, reaction: string): Promise; @@ -2823,6 +2696,7 @@ declare namespace Dysnomia { toJSON(props?: string[]): JSONCache; } + /** @deprecated */ export class CommandClient extends Client { activeMessages: { [s: string]: ActiveMessages }; commandAliases: { [s: string]: string }; @@ -2948,8 +2822,6 @@ declare namespace Dysnomia { members: Collection; mfaLevel: MFALevel; name: string; - /** @deprecated */ - nsfw: boolean; nsfwLevel: NSFWLevel; ownerID: string; preferredLocale: string; @@ -2980,29 +2852,15 @@ declare namespace Dysnomia { addDiscoverySubcategory(categoryID: string, reason?: string): Promise; addMemberRole(memberID: string, roleID: string, reason?: string): Promise; banMember(userID: string, options?: BanMemberOptions): Promise; - /** @deprecated */ - banMember(userID: string, deleteMessageDays?: number, reason?: string): Promise; bulkEditCommands(commands: ApplicationCommandStructure[]): Promise; createAutoModerationRule(rule: CreateAutoModerationRuleOptions): Promise; createChannel(name: string): Promise; createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_TEXT"], options?: CreateChannelOptions): Promise; createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_VOICE"], options?: CreateChannelOptions): Promise; createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_CATEGORY"], options?: CreateChannelOptions): Promise; - createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_NEWS"], options?: CreateChannelOptions | string): Promise; + createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_ANNOUNCEMENT"], options?: CreateChannelOptions | string): Promise; createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_STAGE_VOICE"], options?: CreateChannelOptions | string): Promise; createChannel(name: string, type?: number, options?: CreateChannelOptions): Promise; - /** @deprecated */ - createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_TEXT"], reason?: string, options?: CreateChannelOptions | string): Promise; - /** @deprecated */ - createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_VOICE"], reason?: string, options?: CreateChannelOptions | string): Promise; - /** @deprecated */ - createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_CATEGORY"], reason?: string, options?: CreateChannelOptions | string): Promise; - /** @deprecated */ - createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_NEWS"], reason?: string, options?: CreateChannelOptions | string): Promise; - /** @deprecated */ - createChannel(name: string, type: Constants["ChannelTypes"]["GUILD_STAGE_VOICE"], reason?: string, options?: CreateChannelOptions | string): Promise; - /** @deprecated */ - createChannel(name: string, type?: number, reason?: string, options?: CreateChannelOptions | string): Promise; createCommand(command: T): Promise>; createEmoji(options: { image: string; name: string; roles?: string[] }, reason?: string): Promise; createRole(options: RoleOptions, reason?: string): Promise; @@ -3033,8 +2891,6 @@ declare namespace Dysnomia { editEmoji(emojiID: string, options: { name: string; roles?: string[] }, reason?: string): Promise; editIntegration(integrationID: string, options: IntegrationOptions): Promise; editMember(memberID: string, options: MemberOptions, reason?: string): Promise; - /** @deprecated */ - editNickname(nick: string): Promise; editRole(roleID: string, options: RoleOptions): Promise; editScheduledEvent(eventID: string, event: GuildScheduledEventEditOptions, reason?: string): Promise> editSticker(stickerID: string, options?: EditStickerOptions, reason?: string): Promise; @@ -3043,12 +2899,11 @@ declare namespace Dysnomia { editVoiceState(options: VoiceStateOptions, userID?: string): Promise; editWelcomeScreen(options: WelcomeScreenOptions): Promise; editWidget(options: Widget): Promise; + /** @deprecated */ fetchAllMembers(timeout?: number): Promise; fetchMembers(options?: FetchMembersOptions): Promise; getActiveThreads(): Promise; getAuditLog(options?: GetGuildAuditLogOptions): Promise; - /** @deprecated */ - getAuditLogs(limit?: number, before?: string, actionType?: number, userID?: string): Promise; getAutoModerationRule(guildID: string, ruleID: string): Promise; getAutoModerationRules(guildID: string): Promise; getBan(userID: string): Promise; @@ -3057,8 +2912,6 @@ declare namespace Dysnomia { getCommandPermissions(): Promise; getCommands(): Promise[]>; getDiscovery(): Promise; - /** @deprecated */ - getEmbed(): Promise; getIntegrations(): Promise; getInvites(): Promise; getPruneCount(options?: GetPruneOptions): Promise; @@ -3067,8 +2920,6 @@ declare namespace Dysnomia { getRESTEmojis(): Promise; getRESTMember(memberID: string): Promise; getRESTMembers(options?: GetRESTGuildMembersOptions): Promise; - /** @deprecated */ - getRESTMembers(limit?: number, after?: string): Promise; getRESTRoles(): Promise; getRESTScheduledEvent(eventID: string): Promise; getRESTSticker(stickerID: string): Promise; @@ -3294,8 +3145,6 @@ declare namespace Dysnomia { mention: string; nick: string | null; pending?: boolean; - /** @deprecated */ - permission: Permission; permissions: Permission; premiumSince?: number | null; roles: string[]; @@ -3307,10 +3156,8 @@ declare namespace Dysnomia { constructor(data: BaseData, guild?: Guild, client?: Client); addRole(roleID: string, reason?: string): Promise; ban(options?: BanMemberOptions): Promise; - /** @deprecated */ - ban(deleteMessageDays?: number, reason?: string): Promise; - edit(options: MemberOptions, reason?: string): Promise; dynamicAvatarURL(format?: ImageFormat, size?: number): string; + edit(options: MemberOptions, reason?: string): Promise; kick(reason?: string): Promise; removeRole(roleID: string, reason?: string): Promise; unban(reason?: string): Promise; @@ -3347,8 +3194,6 @@ declare namespace Dysnomia { referencedMessage?: Message | null; roleMentions: string[]; stickerItems?: StickerItem[]; - /** @deprecated */ - stickers?: Sticker[]; timestamp: number; tts: boolean; type: number; @@ -3362,8 +3207,6 @@ declare namespace Dysnomia { edit(content: MessageContent): Promise>; editWebhook(token: string, options: MessageWebhookContent): Promise>; getReaction(reaction: string, options?: GetMessageReactionOptions): Promise; - /** @deprecated */ - getReaction(reaction: string, limit?: number, before?: string, after?: string): Promise; pin(): Promise; removeReaction(reaction: string, userID?: string): Promise; removeReactionEmoji(reaction: string): Promise; @@ -3394,7 +3237,7 @@ declare namespace Dysnomia { // News channel rate limit is always 0 export class NewsChannel extends TextChannel implements GuildPinnable { rateLimitPerUser: 0; - type: Constants["ChannelTypes"]["GUILD_NEWS"]; + type: Constants["ChannelTypes"]["GUILD_ANNOUNCEMENT"]; createInvite(options?: CreateInviteOptions, reason?: string): Promise>; createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; createThreadWithMessage(messageID: string, options: CreateThreadOptions): Promise; @@ -3404,13 +3247,11 @@ declare namespace Dysnomia { getInvites(): Promise<(Invite<"withMetadata", this>)[]>; getMessage(messageID: string): Promise>; getMessages(options?: GetMessagesOptions): Promise[]>; - /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; getPins(): Promise[]>; } export class NewsThreadChannel extends ThreadChannel { - type: Constants["ChannelTypes"]["GUILD_NEWS_THREAD"]; + type: Constants["ChannelTypes"]["ANNOUNCEMENT_THREAD"]; } export class Permission extends Base { @@ -3426,7 +3267,7 @@ declare namespace Dysnomia { type: PermissionType; constructor(data: Overwrite); } - + export class PingInteraction extends Interaction { type: Constants["InteractionTypes"]["PING"]; acknowledge(): Promise; @@ -3462,17 +3303,11 @@ declare namespace Dysnomia { editMessage(messageID: string, content: MessageContentEdit): Promise>; getMessage(messageID: string): Promise>; getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; - /** @deprecated */ - getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; getMessages(options?: GetMessagesOptions): Promise[]>; - /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; getPins(): Promise[]>; leave(): Promise; pinMessage(messageID: string): Promise; removeMessageReaction(messageID: string, reaction: string): Promise; - /** @deprecated */ - removeMessageReaction(messageID: string, reaction: string, userID: string): Promise; sendTyping(): Promise; unpinMessage(messageID: string): Promise; unsendMessage(messageID: string): Promise; @@ -3480,7 +3315,7 @@ declare namespace Dysnomia { export class PrivateThreadChannel extends ThreadChannel { threadMetadata: PrivateThreadMetadata; - type: Constants["ChannelTypes"]["GUILD_PRIVATE_THREAD"]; + type: Constants["ChannelTypes"]["PRIVATE_THREAD"]; } export class PublicThreadChannel extends ThreadChannel { @@ -3496,8 +3331,6 @@ declare namespace Dysnomia { readyQueue: (() => void)[]; userAgent: string; constructor(client: Client, options?: RequestHandlerOptions); - /** @deprecated */ - constructor(client: Client, forceQueueing?: boolean); globalUnblock(): void; request(method: RequestMethod, url: string, auth?: boolean, body?: { [s: string]: unknown }, file?: FileContent, _route?: string, short?: boolean): Promise; routefy(url: string, method: RequestMethod): string; @@ -3546,8 +3379,6 @@ declare namespace Dysnomia { connectTimeout: NodeJS.Timeout | null; discordServerTrace?: string[]; getAllUsersCount: { [guildID: string]: boolean }; - getAllUsersLength: number; - getAllUsersQueue: string; globalBucket: Bucket; guildCreateTimeout: NodeJS.Timeout | null; heartbeatInterval: NodeJS.Timeout | null; @@ -3579,7 +3410,6 @@ declare namespace Dysnomia { emit(event: string, ...args: any[]): void; emit(event: K, ...args: ShardEvents[K]): boolean; emit(event: string, ...args: any[]): boolean; - getGuildMembers(guildID: string, timeout: number): void; hardReset(): void; heartbeat(normal?: boolean): void; identify(): void; @@ -3692,17 +3522,11 @@ declare namespace Dysnomia { getJoinedPrivateArchivedThreads(options: GetArchivedThreadsOptions): Promise>; getMessage(messageID: string): Promise>; getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; - /** @deprecated */ - getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; getMessages(options?: GetMessagesOptions): Promise[]>; - /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; getPins(): Promise[]>; getWebhooks(): Promise; pinMessage(messageID: string): Promise; purge(options: PurgeChannelOptions): Promise; - /** @deprecated */ - purge(limit: number, filter?: (message: Message) => boolean, before?: string, after?: string, reason?: string): Promise; removeMessageReaction(messageID: string, reaction: string, userID?: string): Promise; removeMessageReactionEmoji(messageID: string, reaction: string): Promise; removeMessageReactions(messageID: string): Promise; @@ -3716,8 +3540,6 @@ declare namespace Dysnomia { messages: Collection>; rateLimitPerUser: number; addMessageReaction(messageID: string, reaction: string): Promise; - /** @deprecated */ - addMessageReaction(messageID: string, reaction: string, userID: string): Promise; createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise>; createWebhook(options: { name: string; avatar?: string | null }, reason?: string): Promise; deleteMessage(messageID: string, reason?: string): Promise; @@ -3725,11 +3547,7 @@ declare namespace Dysnomia { editMessage(messageID: string, content: MessageContentEdit): Promise>; getMessage(messageID: string): Promise>; getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; - /** @deprecated */ - getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; getMessages(options?: GetMessagesOptions): Promise[]>; - /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise; getWebhooks(): Promise; purge(options: PurgeChannelOptions): Promise; removeMessageReaction(messageID: string, reaction: string, userID?: string): Promise; @@ -3761,11 +3579,7 @@ declare namespace Dysnomia { getMembers(): Promise; getMessage(messageID: string): Promise>; getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise; - /** @deprecated */ - getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise; getMessages(options?: GetMessagesOptions): Promise[]>; - /** @deprecated */ - getMessages(limit?: number, before?: string, after?: string, around?: string): Promise[]>; getPins(): Promise[]>; join(userID?: string): Promise; leave(userID?: string): Promise; diff --git a/lib/Client.js b/lib/Client.js index 552ac3777..363db4072 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -5,7 +5,6 @@ const Base = require("./structures/Base"); const Channel = require("./structures/Channel"); const Collection = require("./util/Collection"); const Constants = require("./Constants"); -const emitDeprecation = require("./util/emitDeprecation"); const Endpoints = require("./rest/Endpoints"); const ExtendedUser = require("./structures/ExtendedUser"); const Guild = require("./structures/Guild"); @@ -67,21 +66,15 @@ const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); class Client extends EventEmitter { /** * Create a Client - * @arg {String} token The auth token to use. Bot tokens should be prefixed with `Bot` (e.g. `Bot MTExIHlvdSAgdHJpZWQgMTEx.O5rKAA.dQw4w9WgXcQ_wpV-gGA4PSk_bm8`). Prefix-less bot tokens are [DEPRECATED] + * @arg {String} token The auth token to use. Bot tokens should be prefixed with `Bot` (e.g. `Bot MTExIHlvdSAgdHJpZWQgMTEx.O5rKAA.dQw4w9WgXcQ_wpV-gGA4PSk_bm8`). * @arg {Object} options Dysnomia client options - * @arg {Object} [options.agent] [DEPRECATED] A HTTPS Agent used to proxy requests. This option has been moved under `options.rest` * @arg {Object} [options.allowedMentions] A list of mentions to allow by default in createMessage/editMessage * @arg {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here * @arg {Boolean | Array} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow * @arg {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow * @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to - * @arg {Boolean} [options.autoreconnect=true] [DEPRECATED] Have Dysnomia autoreconnect when connection is lost. This option has been moved under `options.gateway` - * @arg {Boolean} [options.compress=false] [DEPRECATED] Whether to request WebSocket data to be compressed or not. This option has been moved under `options.gateway` - * @arg {Number} [options.connectionTimeout=30000] [DEPRECATED] How long in milliseconds to wait for the connection to handshake with the server. This option has been moved under `options.gateway` * @arg {String} [options.defaultImageFormat="jpg"] The default format to provide user avatars, guild icons, and group icons in. Can be "jpg", "png", "gif", or "webp" * @arg {Number} [options.defaultImageSize=128] The default size to return user avatars, guild icons, banners, splashes, and group icons. Can be any power of two between 16 and 2048. If the height and width are different, the width will be the value specified, and the height relative to that - * @arg {Object} [options.disableEvents] [DEPRECATED] If disableEvents[eventName] is true, the WS event will not be processed. This can cause significant performance increase on large bots. [A full list of the WS event names can be found in Discord's documentation](https://discord.com/developers/docs/topics/gateway-events#receive-events). This option has been moved under `options.gateway` - * @arg {Number} [options.firstShardID=0] [DEPRECATED] The ID of the first shard to run for this client. This option has been moved under `options.gateway` * @arg {Object} [options.gateway] Options for gateway connections * @arg {Boolean} [options.gateway.autoreconnect=true] Have Dysnomia autoreconnect when connection is lost * @arg {Boolean} [options.gateway.compress=false] Whether to request WebSocket data to be compressed or not @@ -99,24 +92,12 @@ class Client extends EventEmitter { * @arg {Number | String} [options.gateway.maxShards=1] The total number of shards you want to run. If "auto" Dysnomia will use Discord's recommended shard count. * @arg {Function} [options.gateway.reconnectDelay] A function which returns how long the bot should wait until reconnecting to Discord. * @arg {Boolean} [options.gateway.seedVoiceConnections=false] Whether to populate bot.voiceConnections with existing connections the bot account has during startup. Note that this will disconnect connections from other bot sessions - * @arg {Boolean} [options.getAllUsers=false] [DEPRECATED] Get all the users in every guild. Ready time will be severely delayed. This option has been moved under `options.gateway` - * @arg {Number} [options.guildCreateTimeout=2000] [DEPRECATED] How long in milliseconds to wait for a GUILD_CREATE before "ready" is fired. Increase this value if you notice missing guilds. This option has been moved under `options.gateway` - * @arg {Number | Array} [options.intents] [DEPRECATED] A list of [intent names](https://github.com/projectdysnomia/dysnomia/blob/dev/lib/Constants.js#L311), pre-shifted intent numbers to add, or a raw bitmask value describing the intents to subscribe to. Some intents, like `guildPresences` and `guildMembers`, must be enabled on your application's page to be used. By default, all non-privileged intents are enabled. This option has been moved under `options.gateway` - * @arg {Number} [options.largeThreshold=250] [DEPRECATED] The maximum number of offline users per guild during initial guild data transmission. This option has been moved under `options.gateway` - * @arg {Number} [options.lastShardID=options.maxShards - 1] [DEPRECATED] The ID of the last shard to run for this client. This option has been moved under `options.gateway` - * @arg {Number} [options.latencyThreshold=30000] [DEPRECATED] The average request latency at which Dysnomia will start emitting latency errors. This option has been moved under `options.rest` - * @arg {Number} [options.maxReconnectAttempts=Infinity] [DEPRECATED] The maximum amount of times that the client is allowed to try to reconnect to Discord. This option has been moved under `options.gateway` - * @arg {Number} [options.maxResumeAttempts=10] [DEPRECATED] The maximum amount of times a shard can attempt to resume a session before considering that session invalid. This option has been moved under `options.gateway` * @arg {Number | String} [options.maxShards=1] The total number of shards you want to run. If "auto" Dysnomia will use Discord's recommended shard count. This option has been moved under `options.gateway` * @arg {Number} [options.messageLimit=100] The maximum size of a channel message cache * @arg {Boolean} [options.opusOnly=false] Whether to suppress the Opus encoder not found error or not - * @arg {Number} [options.ratelimiterOffset=0] [DEPRECATED] A number of milliseconds to offset the ratelimit timing calculations by. This option has been moved under `options.rest` - * @arg {Function} [options.reconnectDelay] [DEPRECATED] A function which returns how long the bot should wait until reconnecting to Discord. This option has been moved under `options.gateway` - * @arg {Number} [options.requestTimeout=15000] A number of milliseconds before requests are considered timed out. This option will stop affecting REST in a future release; that behavior is [DEPRECATED] and replaced by `options.rest.requestTimeout` * @arg {Object} [options.rest] Options for the REST request handler * @arg {Object} [options.rest.agent] A HTTPS Agent (if https: true, default) or an HTTP agent (if https: false) used to proxy requests * @arg {String} [options.rest.baseURL] The base URL to use for API requests. Defaults to `/api/v${REST_VERSION}` - * @arg {Boolean} [options.rest.decodeReasons=true] [DEPRECATED] Whether reasons should be decoded with `decodeURIComponent()` when making REST requests. This is true by default to mirror pre-0.15.0 behavior (where reasons were expected to be URI-encoded), and should be set to false once your bot code stops. Reasons will no longer be decoded in the future * @arg {Boolean} [options.rest.disableLatencyCompensation=false] Whether to disable the built-in latency compensator or not * @arg {String} [options.rest.domain="discord.com"] The domain to use for API requests * @arg {Boolean} [options.rest.https=true] Whether to make requests to the Discord API over HTTPS (true) or HTTP (false) @@ -124,7 +105,6 @@ class Client extends EventEmitter { * @arg {Number} [options.rest.ratelimiterOffset=0] A number of milliseconds to offset the ratelimit timing calculations by * @arg {Number} [options.rest.requestTimeout=15000] A number of milliseconds before REST requests are considered timed out * @arg {Boolean} [options.restMode=false] Whether to enable getting objects over REST. Even with this option enabled, it is recommended that you check the cache first before using REST - * @arg {Boolean} [options.seedVoiceConnections=false] [DEPRECATED] Whether to populate bot.voiceConnections with existing connections the bot account has during startup. Note that this will disconnect connections from other bot sessions. This option has been moved under `options.gateway` * @arg {Object} [options.ws] An object of WebSocket options to pass to the shard WebSocket constructors */ constructor(token, options) { @@ -139,7 +119,6 @@ class Client extends EventEmitter { defaultImageSize: 128, messageLimit: 100, opusOnly: false, - requestTimeout: 15000, rest: {}, restMode: false, ws: {}, @@ -154,9 +133,9 @@ class Client extends EventEmitter { throw new TypeError(`Invalid default image size: ${defaultImageSize}`); } // Set HTTP Agent on Websockets if not already set - if(this.options.agent && !(this.options.ws && this.options.ws.agent)) { + if(this.options.rest.agent && !(this.options.ws && this.options.ws.agent)) { this.options.ws = this.options.ws || {}; - this.options.ws.agent = this.options.agent; + this.options.ws.agent = this.options.rest.agent; } Object.defineProperty(this, "_token", { @@ -231,42 +210,24 @@ class Client extends EventEmitter { * @arg {String} channelID The ID of the channel * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {String} [userID="@me"] The ID of the user to react as. Passing this parameter is deprecated and will not be supported in future versions. * @returns {Promise} */ - addMessageReaction(channelID, messageID, reaction, userID) { - if(userID !== undefined) { - emitDeprecation("REACTION_USER"); - this.emit("warn", "[DEPRECATED] addMessageReaction() was called without an \"@me\" `userID` argument"); - } + addMessageReaction(channelID, messageID, reaction) { if(reaction === decodeURI(reaction)) { reaction = encodeURIComponent(reaction); } - return this.requestHandler.request("PUT", Endpoints.CHANNEL_MESSAGE_REACTION_USER(channelID, messageID, reaction, userID || "@me"), true); + return this.requestHandler.request("PUT", Endpoints.CHANNEL_MESSAGE_REACTION_USER(channelID, messageID, reaction, "@me"), true); } /** * Ban a user from a guild * @arg {String} guildID The ID of the guild * @arg {String} userID The ID of the user - * @arg {Number} [options.deleteMessageDays=0] [DEPRECATED] Number of days to delete messages for, between 0-7 inclusive * @arg {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604800 inclusive * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs * @returns {Promise} */ - banGuildMember(guildID, userID, options, reason) { - if(!options || typeof options !== "object") { - options = { - deleteMessageDays: options - }; - } - if(reason !== undefined) { - options.reason = reason; - } - if(options.deleteMessageDays && !isNaN(options.deleteMessageDays) && !Object.hasOwnProperty.call(options, "deleteMessageSeconds")) { - options.deleteMessageSeconds = options.deleteMessageDays * 24 * 60 * 60; - } + banGuildMember(guildID, userID, options) { return this.requestHandler.request("PUT", Endpoints.GUILD_BAN(guildID, userID), true, { delete_message_seconds: options.deleteMessageSeconds || 0, reason: options.reason @@ -427,7 +388,7 @@ class Client extends EventEmitter { * @arg {String} guildID The ID of the guild to create the channel in * @arg {String} name The name of the channel * @arg {String} [type=0] The type of the channel, either 0 (text), 2 (voice), 4 (category), 5 (news), or 13 (stage) - * @arg {Object | String} [options] The properties the channel should have. If `options` is a string, it will be treated as `options.parentID` (see below). Passing a string is deprecated and will not be supported in future versions. + * @arg {Object | String} [options] The properties the channel should have. * @arg {Number} [options.bitrate] The bitrate of the channel (voice channels only) * @arg {Boolean} [options.nsfw] The nsfw status of the channel * @arg {String?} [options.parentID] The ID of the parent category channel for this channel @@ -439,23 +400,7 @@ class Client extends EventEmitter { * @arg {Number} [options.userLimit] The channel user limit (voice channels only) * @returns {Promise} */ - createChannel(guildID, name, type, reason, options = {}) { - if(typeof options === "string") { // This used to be parentID, back-compat - emitDeprecation("CREATE_CHANNEL_OPTIONS"); - this.emit("warn", "[DEPRECATED] createChannel() was called with a string `options` argument"); - options = { - parentID: options - }; - } - if(typeof reason === "string") { // Reason is deprecated, will be folded into options - emitDeprecation("CREATE_CHANNEL_OPTIONS"); - this.emit("warn", "[DEPRECATED] createChannel() was called with a string `reason` argument"); - options.reason = reason; - reason = undefined; - } else if(typeof reason === "object" && reason !== null) { - options = reason; - reason = undefined; - } + createChannel(guildID, name, type, options = {}) { return this.requestHandler.request("POST", Endpoints.GUILD_CHANNELS(guildID), true, { name: name, type: type, @@ -748,7 +693,6 @@ class Client extends EventEmitter { * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead * @arg {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send * @arg {Boolean} [content.tts] Set the message TTS flag * @arg {Object | Array} [file] A file object (or an Array of them) @@ -764,11 +708,6 @@ class Client extends EventEmitter { }; } else if(content.content !== undefined && typeof content.content !== "string") { content.content = "" + content.content; - } else if(content.embed) { - if(!content.embeds) { - content.embeds = []; - } - content.embeds.push(content.embed); } content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions); content.sticker_ids = content.stickerIDs; @@ -790,10 +729,6 @@ class Client extends EventEmitter { content.message_reference.fail_if_not_exists = content.messageReference.failIfNotExists; content.messageReference.failIfNotExists = undefined; } - } else if(content.messageReferenceID) { - emitDeprecation("MESSAGE_REFERENCE"); - this.emit("warn", "[DEPRECATED] content.messageReferenceID is deprecated. Use content.messageReference instead"); - content.message_reference = {message_id: content.messageReferenceID}; } } return this.requestHandler.request("POST", Endpoints.CHANNEL_MESSAGES(channelID), true, content, file).then((message) => new Message(message, this)); @@ -1633,7 +1568,6 @@ class Client extends EventEmitter { * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure * @arg {String} [content.content] A content string - * @arg {Object} [content.embed] An embed object. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Object | Array} [content.file] A file object (or an Array of them) * @arg {Buffer} content.file[].file A buffer containing file data @@ -1649,11 +1583,6 @@ class Client extends EventEmitter { }; } else if(content.content !== undefined && typeof content.content !== "string") { content.content = "" + content.content; - } else if(content.embed) { - if(!content.embeds) { - content.embeds = []; - } - content.embeds.push(content.embed); } if(content.content !== undefined || content.embeds || content.allowedMentions) { content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions); @@ -1662,20 +1591,6 @@ class Client extends EventEmitter { return this.requestHandler.request("PATCH", Endpoints.CHANNEL_MESSAGE(channelID, messageID), true, content, content.file).then((message) => new Message(message, this)); } - /** - * [DEPRECATED] Edit the bot's nickname in a guild - * @arg {String} guildID The ID of the guild - * @arg {String} nick The nickname - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ - editNickname(guildID, nick, reason) { - return this.requestHandler.request("PATCH", Endpoints.GUILD_MEMBER_NICK(guildID, "@me"), true, { - nick, - reason - }); - } - /** * Edit a guild role * @arg {String} guildID The ID of the guild the role is in @@ -1984,9 +1899,6 @@ class Client extends EventEmitter { * @returns {Promise} Resolves with an object containing gateway connection info */ getBotGateway() { - if(!this._token.startsWith("Bot ")) { - this._token = "Bot " + this._token; - } return this.requestHandler.request("GET", Endpoints.GATEWAY_BOT, true); } @@ -2106,31 +2018,17 @@ class Client extends EventEmitter { /** * Get the audit log for a guild * @arg {String} guildID The ID of the guild to get audit logs for - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request * @arg {Number} [options.actionType] Filter entries by action type * @arg {String} [options.before] Get entries before this entry ID * @arg {Number} [options.limit=50] The maximum number of entries to return * @arg {String} [options.userID] Filter entries by the user that performed the action * @returns {Promise<{entries: Array, integrations: Array, threads: Array, users: Array, webhooks: Array}>} */ - getGuildAuditLog(guildID, options = {}, before, actionType, userID) { - if(!options || typeof options !== "object") { - options = { - limit: options - }; - } + getGuildAuditLog(guildID, options = {}) { if(options.limit === undefined) { // Legacy behavior options.limit = 50; } - if(actionType !== undefined) { - options.actionType = actionType; - } - if(before !== undefined) { - options.before = before; - } - if(userID !== undefined) { - options.userID = userID; - } if(options.actionType !== undefined) { options.action_type = options.actionType; } @@ -2151,19 +2049,6 @@ class Client extends EventEmitter { }); } - /** - * [DEPRECATED] Get the audit log for a guild. Use `getGuildAuditLog` instead - * @arg {String} guildID The ID of the guild to get audit logs for - * @arg {Object} [limit=50] The maximum number of entries to return - * @arg {String} [before] Get entries before this entry ID - * @arg {Number} [actionType] Filter entries by action type - * @arg {String} [userID] Filter entries by the user that performed the action - * @returns {Promise<{users: Array, entries: Array, integrations: Array, webhooks: Array}>} - */ - getGuildAuditLogs(guildID, limit, before, actionType, userID) { - return this.getGuildAuditLog.call(this, guildID, limit, before, actionType, userID); - } - /** * Get a ban from the ban list of a guild * @arg {String} guildID The ID of the guild @@ -2438,69 +2323,35 @@ class Client extends EventEmitter { * @arg {String} channelID The ID of the channel * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request * @arg {Number} [options.limit=100] The maximum number of users to get * @arg {String} [options.after] Get users after this user ID - * @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter - * @arg {String} [after] [DEPRECATED] Get users after this user ID * @returns {Promise>} */ - getMessageReaction(channelID, messageID, reaction, options = {}, before, after) { + getMessageReaction(channelID, messageID, reaction, options = {}) { if(reaction === decodeURI(reaction)) { reaction = encodeURIComponent(reaction); } - if(!options || typeof options !== "object") { - options = { - limit: options - }; - } if(options.limit === undefined) { // Legacy behavior options.limit = 100; } - if(before !== undefined) { - options.before = before; - } - if(after !== undefined) { - options.after = after; - } - if(options.before) { - emitDeprecation("GET_REACTION_BEFORE"); - this.emit("warn", "[DEPRECATED] getMessageReaction() was called with a `before` parameter. Discord no longer supports this parameter"); - } return this.requestHandler.request("GET", Endpoints.CHANNEL_MESSAGE_REACTION(channelID, messageID, reaction), true, options).then((users) => users.map((user) => new User(user, this))); } /** * Get previous messages in a channel * @arg {String} channelID The ID of the channel - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request. * @arg {String} [options.after] Get messages after this message ID * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) * @arg {String} [options.before] Get messages before this message ID * @arg {Number} [options.limit=50] The max number of messages to get - * @arg {String} [before] [DEPRECATED] Get messages before this message ID - * @arg {String} [after] [DEPRECATED] Get messages after this message ID - * @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100) * @returns {Promise>} */ - async getMessages(channelID, options = {}, before, after, around) { - if(!options || typeof options !== "object") { - options = { - limit: options - }; - } + async getMessages(channelID, options = {}) { if(options.limit === undefined) { // Legacy behavior options.limit = 50; } - if(after !== undefined) { - options.after = after; - } - if(around !== undefined) { - options.around = around; - } - if(before !== undefined) { - options.before = before; - } let limit = options.limit; if(limit && limit > 100) { let logs = []; @@ -2656,24 +2507,15 @@ class Client extends EventEmitter { /** * Get a guild's members via the REST API. REST mode is required to use this endpoint. * @arg {String} guildID The ID of the guild - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request. * @arg {String} [options.after] The highest user ID of the previous page * @arg {Number} [options.limit=1] The max number of members to get (1 to 1000) - * @arg {String} [after] [DEPRECATED] The highest user ID of the previous page * @returns {Promise>} */ - getRESTGuildMembers(guildID, options = {}, after) { + getRESTGuildMembers(guildID, options = {}) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); } - if(!options || typeof options !== "object") { - options = { - limit: options - }; - } - if(after !== undefined) { - options.after = after; - } return this.requestHandler.request("GET", Endpoints.GUILD_MEMBERS(guildID), true, options).then((members) => members.map((member) => new Member(member, this.guilds.get(guildID), this))); } @@ -2691,30 +2533,17 @@ class Client extends EventEmitter { /** * Get a list of the user's guilds via the REST API. REST mode is required to use this endpoint. - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request. * @arg {String} [options.after] The highest guild ID of the previous page * @arg {String} [options.before] The lowest guild ID of the next page * @arg {Number} [options.limit=100] The max number of guilds to get (1 to 1000) - * @arg {String} [before] [DEPRECATED] The lowest guild ID of the next page - * @arg {String} [after] [DEPRECATED] The highest guild ID of the previous page * @returns {Promise>} */ - getRESTGuilds(options = {}, before, after) { + getRESTGuilds(options = {}) { // TODO type if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); } - if(!options || typeof options !== "object") { - options = { - limit: options - }; - } - if(after !== undefined) { - options.after = after; - } - if(before !== undefined) { - options.before = before; - } return this.requestHandler.request("GET", Endpoints.USER_GUILDS("@me"), true, options).then((guilds) => guilds.map((guild) => new Guild(guild, this))); } @@ -2955,36 +2784,15 @@ class Client extends EventEmitter { /** * Purge previous messages in a channel with an optional filter (bot accounts only) * @arg {String} channelID The ID of the channel - * @arg {Object} options Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} options Options for the request. * @arg {String} [options.after] Get messages after this message ID * @arg {String} [options.before] Get messages before this message ID * @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object * @arg {Number} options.limit The max number of messages to search through, -1 for no limit * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Function} [filter] [DEPRECATED] Optional filter function that returns a boolean when passed a Message object - * @arg {String} [before] [DEPRECATED] Get messages before this message ID - * @arg {String} [after] [DEPRECATED] Get messages after this message ID - * @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs * @returns {Promise} Resolves with the number of messages deleted */ - async purgeChannel(channelID, options, filter, before, after, reason) { - if(!options || typeof options !== "object") { - options = { - limit: options - }; - } - if(after !== undefined) { - options.after = after; - } - if(before !== undefined) { - options.before = before; - } - if(filter !== undefined) { - options.filter = filter; - } - if(reason !== undefined) { - options.reason = reason; - } + async purgeChannel(channelID, options) { if(typeof options.filter === "string") { const filter = options.filter; options.filter = (msg) => msg.content.includes(filter); diff --git a/lib/Constants.js b/lib/Constants.js index 3bdee4543..88cae4aaa 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -181,12 +181,12 @@ module.exports.ChannelTypes = { GUILD_VOICE: 2, GROUP_DM: 3, GUILD_CATEGORY: 4, - GUILD_NEWS: 5, + GUILD_ANNOUNCEMENT: 5, GUILD_NEWS: 5, // [DEPRECATED] - GUILD_NEWS_THREAD: 10, - GUILD_PUBLIC_THREAD: 11, - GUILD_PRIVATE_THREAD: 12, - GUILD_STAGE_VOICE: 13, GUILD_STAGE: 13 // [DEPRECATED] + ANNOUNCEMENT_THREAD: 10, GUILD_NEWS_THREAD: 10, // [DEPRECATED] + PUBLIC_THREAD: 11, GUILD_PUBLIC_THREAD: 11, // [DEPRECATED] + PRIVATE_THREAD: 12, GUILD_PRIVATE_THREAD: 12, // [DEPRECATED] + GUILD_STAGE_VOICE: 13 }; module.exports.ComponentTypes = { @@ -213,15 +213,15 @@ module.exports.ExplicitContentFilterLevels = { }; module.exports.GatewayOPCodes = { - DISPATCH: 0, EVENT: 0, // [DEPRECATED] + DISPATCH: 0, HEARTBEAT: 1, IDENTIFY: 2, - PRESENCE_UPDATE: 3, STATUS_UPDATE: 3, // [DEPRECATED] + PRESENCE_UPDATE: 3, VOICE_STATE_UPDATE: 4, VOICE_SERVER_PING: 5, RESUME: 6, RECONNECT: 7, - REQUEST_GUILD_MEMBERS: 8, GET_GUILD_MEMBERS: 8, // [DEPRECATED] + REQUEST_GUILD_MEMBERS: 8, INVALID_SESSION: 9, HELLO: 10, HEARTBEAT_ACK: 11 @@ -312,7 +312,7 @@ const Intents = { guilds: 1 << 0, guildMembers: 1 << 1, guildBans: 1 << 2, - guildEmojisAndStickers: 1 << 3, guildEmojis: 1 << 3, // [DEPRECATED] + guildEmojisAndStickers: 1 << 3, guildIntegrations: 1 << 4, guildWebhooks: 1 << 5, guildInvites: 1 << 6, @@ -447,10 +447,10 @@ const Permissions = { manageChannels: 1n << 4n, manageGuild: 1n << 5n, addReactions: 1n << 6n, - viewAuditLog: 1n << 7n, viewAuditLogs: 1n << 7n, // [DEPRECATED] + viewAuditLog: 1n << 7n, voicePrioritySpeaker: 1n << 8n, - voiceStream: 1n << 9n, stream: 1n << 9n, // [DEPRECATED] - viewChannel: 1n << 10n, readMessages: 1n << 10n, // [DEPRECATED] + voiceStream: 1n << 9n, + viewChannel: 1n << 10n, sendMessages: 1n << 11n, sendTTSMessages: 1n << 12n, manageMessages: 1n << 13n, @@ -458,7 +458,7 @@ const Permissions = { attachFiles: 1n << 15n, readMessageHistory: 1n << 16n, mentionEveryone: 1n << 17n, - useExternalEmojis: 1n << 18n, externalEmojis: 1n << 18n, // [DEPRECATED] + useExternalEmojis: 1n << 18n, viewGuildInsights: 1n << 19n, voiceConnect: 1n << 20n, voiceSpeak: 1n << 21n, @@ -470,8 +470,8 @@ const Permissions = { manageNicknames: 1n << 27n, manageRoles: 1n << 28n, manageWebhooks: 1n << 29n, - manageEmojisAndStickers: 1n << 30n, manageEmojis: 1n << 30n, // [DEPRECATED] - useApplicationCommands: 1n << 31n, useSlashCommands: 1n << 31n, // [DEPRECATED] + manageEmojisAndStickers: 1n << 30n, + useApplicationCommands: 1n << 31n, voiceRequestToSpeak: 1n << 32n, manageEvents: 1n << 33n, manageThreads: 1n << 34n, @@ -624,20 +624,20 @@ module.exports.TextInputStyles = { module.exports.UserFlags = { NONE: 0, - DISCORD_STAFF: 1 << 0, DISCORD_EMPLOYEE: 1 << 0, + STAFF: 1 << 0, DISCORD_STAFF: 1 << 0, DISCORD_EMPLOYEE: 1 << 0, // [DEPRECATED] PARTNER: 1 << 1, PARTNERED_SERVER_OWNER: 1 << 1, DISCORD_PARTNER: 1 << 1, // [DEPRECATED] - HYPESQUAD: 1 << 2, HYPESQUAD_EVENTS: 1 << 2, + HYPESQUAD: 1 << 2, HYPESQUAD_EVENTS: 1 << 2, // [DEPRECATED] BUG_HUNTER_LEVEL_1: 1 << 3, - HOUSE_BRAVERY: 1 << 6, HYPESQUAD_ONLINE_HOUSE_1: 1 << 6, - HOUSE_BRILLIANCE: 1 << 7, HYPESQUAD_ONLINE_HOUSE_2: 1 << 7, - HOUSE_BALANCE: 1 << 8, HYPESQUAD_ONLINE_HOUSE_3: 1 << 8, - PREMIUM_EARLY_SUPPORTER: 1 << 9, EARLY_SUPPORTER: 1 << 9, - TEAM_PSEUDO_USER: 1 << 10, TEAM_USER: 1 << 10, + HHYPESQUAD_ONLINE_HOUSE_1: 1 << 6, HOUSE_BRAVERY : 1 << 6, // [DEPRECATED] + HYPESQUAD_ONLINE_HOUSE_2: 1 << 7, HOUSE_BRILLIANCE: 1 << 7, // [DEPRECATED] + HYPESQUAD_ONLINE_HOUSE_3: 1 << 8, HOUSE_BALANCE: 1 << 8, // [DEPRECATED] + PREMIUM_EARLY_SUPPORTER: 1 << 9, EARLY_SUPPORTER: 1 << 9, // [DEPRECATED] + TEAM_PSEUDO_USER: 1 << 10, TEAM_USER: 1 << 10, // [DEPRECATED] SYSTEM: 1 << 12, BUG_HUNTER_LEVEL_2: 1 << 14, VERIFIED_BOT: 1 << 16, - VERIFIED_DEVELOPER: 1 << 17, EARLY_VERIFIED_BOT_DEVELOPER: 1 << 17, VERIFIED_BOT_DEVELOPER: 1 << 17, - CERTIFIED_MODERATOR: 1 << 18, DISCORD_CERTIFIED_MODERATOR: 1 << 18, + VERIFIED_DEVELOPER: 1 << 17, EARLY_VERIFIED_BOT_DEVELOPER: 1 << 17, VERIFIED_BOT_DEVELOPER: 1 << 17, // [DEPRECATED] + CERTIFIED_MODERATOR: 1 << 18, DISCORD_CERTIFIED_MODERATOR: 1 << 18, // [DEPRECATED] BOT_HTTP_INTERACTIONS: 1 << 19, SPAMMER: 1 << 20 }; @@ -666,7 +666,7 @@ module.exports.VoiceOPCodes = { RESUME: 7, HELLO: 8, RESUMED: 9, - CLIENT_DISCONNECT: 13, DISCONNECT: 13 // [DEPRECATED] + CLIENT_DISCONNECT: 13 }; module.exports.WebhookTypes = { diff --git a/lib/command/CommandClient.js b/lib/command/CommandClient.js index eceb03f6c..7ea87a6e5 100644 --- a/lib/command/CommandClient.js +++ b/lib/command/CommandClient.js @@ -5,7 +5,7 @@ const Command = require("./Command"); const Message = require("../structures/Message"); /** -* Represents a Dysnomia client with the command framework +* [DEPRECATED] Represents a Dysnomia client with the command framework * @extends Client * @prop {Object} commands Object mapping command labels to Command objects * @prop {Object} commandAliases Object mapping command label aliases to command labels diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 6f15db54c..a24701e37 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -70,12 +70,6 @@ class Shard extends EventEmitter { checkReady() { if(!this.ready) { - if(this.getAllUsersQueue.length > 0) { - this.requestGuildMembers(this.getAllUsersQueue); - this.getAllUsersQueue = []; - this.getAllUsersLength = 1; - return; - } if(Object.keys(this.getAllUsersCount).length === 0) { this.ready = true; /** @@ -104,7 +98,8 @@ class Shard extends EventEmitter { this.client.guildShardMap[_guild.id] = this.id; const guild = this.client.guilds.add(_guild, this.client, true); if(this.client.options.getAllUsers && guild.members.size < guild.memberCount) { - this.getGuildMembers(guild.id, { + this.getAllUsersCount[guild.id] = true; + this.requestGuildMembers(guild.id, { presences: this.client.shards.options.intents && this.client.shards.options.intents & Constants.Intents.guildPresences }); } @@ -235,29 +230,6 @@ class Shard extends EventEmitter { } } - getGuildMembers(guildID, timeout) { - if(this.getAllUsersCount.hasOwnProperty(guildID)) { - throw new Error("Cannot request all members while an existing request is processing"); - } - this.getAllUsersCount[guildID] = true; - // Using intents, request one guild at a time - if(this.client.shards.options.intents) { - if(!(this.client.shards.options.intents & Constants.Intents.guildMembers)) { - throw new Error("Cannot request all members without guildMembers intent"); - } - this.requestGuildMembers([guildID], timeout); - } else { - if(this.getAllUsersLength + 3 + guildID.length > 4048) { // 4096 - "{\"op\":8,\"d\":{\"guild_id\":[],\"query\":\"\",\"limit\":0}}".length + 1 for lazy comma offset - this.requestGuildMembers(this.getAllUsersQueue); - this.getAllUsersQueue = [guildID]; - this.getAllUsersLength = 1 + guildID.length + 3; - } else { - this.getAllUsersQueue.push(guildID); - this.getAllUsersLength += guildID.length + 3; - } - } - } - hardReset() { this.reset(); this.seq = 0; @@ -512,8 +484,6 @@ class Shard extends EventEmitter { } this.requestMembersPromise = {}; this.getAllUsersCount = {}; - this.getAllUsersQueue = []; - this.getAllUsersLength = 1; this.latency = Infinity; this.lastHeartbeatAck = true; this.lastHeartbeatReceived = null; @@ -1308,7 +1278,6 @@ class Shard extends EventEmitter { maxVideoChannelUsers: guild.maxVideoChannelUsers, mfaLevel: guild.mfaLevel, name: guild.name, - nsfw: guild.nsfw, nsfwLevel: guild.nsfwLevel, ownerID: guild.ownerID, preferredLocale: guild.preferredLocale, @@ -1342,7 +1311,6 @@ class Shard extends EventEmitter { * @prop {Number?} oldGuild.maxVideoChannelUsers The max number of users allowed in a video channel * @prop {Number} oldGuild.mfaLevel The admin 2FA level for the guild. 0 is not required, 1 is required * @prop {String} oldGuild.name The name of the guild - * @prop {Boolean} oldGuild.nsfw [DEPRECATED] Whether the guild is designated as NSFW by Discord * @prop {Number} oldGuild.nsfwLevel The guild NSFW level designated by Discord * @prop {String} oldGuild.ownerID The ID of the user that is the guild owner * @prop {String} oldGuild.preferredLocale Preferred "COMMUNITY" guild language used in server discovery and notices from Discord @@ -2425,8 +2393,6 @@ class Shard extends EventEmitter { "latency", "preReady", "getAllUsersCount", - "getAllUsersQueue", - "getAllUsersLength", "lastHeartbeatAck", "seq", "sessionID", diff --git a/lib/gateway/ShardManager.js b/lib/gateway/ShardManager.js index 661c7fd50..4bde46832 100644 --- a/lib/gateway/ShardManager.js +++ b/lib/gateway/ShardManager.js @@ -18,26 +18,23 @@ class ShardManager extends Collection { super(Shard); this._client = client; this.options = Object.assign({ - autoreconnect: typeof client.options.autoreconnect !== "undefined" ? client.options.autoreconnect : true, - compress: typeof client.options.compress !== "undefined" ? client.options.compress : false, - connectionTimeout: typeof client.options.connectionTimeout !== "undefined" ? client.options.connectionTimeout : 30000, + autoreconnect: true, + compress: false, + connectionTimeout: 30000, disableEvents: {}, - firstShardID: typeof client.options.firstShardID !== "undefined" ? client.options.firstShardID : 0, - getAllUsers: typeof client.options.getAllUsers !== "undefined" ? client.options.getAllUsers : false, - guildCreateTimeout: typeof client.options.guildCreateTimeout !== "undefined" ? client.options.guildCreateTimeout : 2000, - intents: typeof client.options.intents !== "undefined" ? client.options.intents : Constants.Intents.allNonPrivileged, - largeThreshold: typeof client.options.largeThreshold !== "undefined" ? client.options.largeThreshold : 250, - maxReconnectAttempts: typeof client.options.maxReconnectAttempts !== "undefined" ? client.options.maxReconnectAttempts : Infinity, - maxResumeAttempts: typeof client.options.maxResumeAttempts !== "undefined" ? client.options.maxResumeAttempts : 10, - maxConcurrency: typeof client.options.maxConcurrency !== "undefined" ? client.options.maxConcurrency : 1, - maxShards: typeof client.options.maxShards !== "undefined" ? client.options.maxShards : 1, - seedVoiceConnections: typeof client.options.seedVoiceConnections !== "undefined" ? client.options.seedVoiceConnections : false, - reconnectDelay: client.options.reconnectDelay || ((lastDelay, attempts) => Math.pow(attempts + 1, 0.7) * 20000) + firstShardID: 0, + getAllUsers: false, + guildCreateTimeout: 2000, + intents: Constants.Intents.allNonPrivileged, + largeThreshold: 250, + maxReconnectAttempts: Infinity, + maxResumeAttempts: 10, + maxConcurrency: 1, + maxShards: 1, + seedVoiceConnections: false, + reconnectDelay: ((lastDelay, attempts) => Math.pow(attempts + 1, 0.7) * 20000) }, options); - if(typeof client.options.disableEvents !== "undefined") { - this.options.disableEvents = Object.assign(client.options.disableEvents, this.options.disableEvents); - } if(typeof this.options.intents !== "undefined") { // Resolve intents option to the proper integer if(Array.isArray(this.options.intents)) { diff --git a/lib/rest/Endpoints.js b/lib/rest/Endpoints.js index 1f09a9016..adcd506ee 100644 --- a/lib/rest/Endpoints.js +++ b/lib/rest/Endpoints.js @@ -22,14 +22,11 @@ module.exports.CHANNEL_MESSAGE_REACTION_USER = (chanID, msgID, reaction, userID) module.exports.CHANNEL_MESSAGE_REACTIONS = (chanID, msgID) => `/channels/${chanID}/messages/${msgID}/reactions`; module.exports.CHANNEL_MESSAGE = (chanID, msgID) => `/channels/${chanID}/messages/${msgID}`; module.exports.CHANNEL_MESSAGES = (chanID) => `/channels/${chanID}/messages`; -module.exports.CHANNEL_MESSAGES_SEARCH = (chanID) => `/channels/${chanID}/messages/search`; module.exports.CHANNEL_PERMISSION = (chanID, overID) => `/channels/${chanID}/permissions/${overID}`; -module.exports.CHANNEL_PERMISSIONS = (chanID) => `/channels/${chanID}/permissions`; module.exports.CHANNEL_PIN = (chanID, msgID) => `/channels/${chanID}/pins/${msgID}`; module.exports.CHANNEL_PINS = (chanID) => `/channels/${chanID}/pins`; module.exports.CHANNEL_TYPING = (chanID) => `/channels/${chanID}/typing`; module.exports.CHANNEL_WEBHOOKS = (chanID) => `/channels/${chanID}/webhooks`; -module.exports.CHANNELS = "/channels"; module.exports.CUSTOM_EMOJI_GUILD = (emojiID) => `/emojis/${emojiID}/guild`; module.exports.DISCOVERY_CATEGORIES = "/discovery/categories"; module.exports.DISCOVERY_VALIDATION = "/discovery/valid-term"; @@ -48,16 +45,13 @@ module.exports.GUILD_DISCOVERY_CATEGORY = (guildID, categoryID) module.exports.GUILD_EMOJI = (guildID, emojiID) => `/guilds/${guildID}/emojis/${emojiID}`; module.exports.GUILD_EMOJIS = (guildID) => `/guilds/${guildID}/emojis`; module.exports.GUILD_INTEGRATION = (guildID, inteID) => `/guilds/${guildID}/integrations/${inteID}`; -module.exports.GUILD_INTEGRATION_SYNC = (guildID, inteID) => `/guilds/${guildID}/integrations/${inteID}/sync`; module.exports.GUILD_INTEGRATIONS = (guildID) => `/guilds/${guildID}/integrations`; module.exports.GUILD_INVITES = (guildID) => `/guilds/${guildID}/invites`; module.exports.GUILD_VANITY_URL = (guildID) => `/guilds/${guildID}/vanity-url`; module.exports.GUILD_MEMBER = (guildID, memberID) => `/guilds/${guildID}/members/${memberID}`; -module.exports.GUILD_MEMBER_NICK = (guildID, memberID) => `/guilds/${guildID}/members/${memberID}/nick`; module.exports.GUILD_MEMBER_ROLE = (guildID, memberID, roleID) => `/guilds/${guildID}/members/${memberID}/roles/${roleID}`; module.exports.GUILD_MEMBERS = (guildID) => `/guilds/${guildID}/members`; module.exports.GUILD_MEMBERS_SEARCH = (guildID) => `/guilds/${guildID}/members/search`; -module.exports.GUILD_MESSAGES_SEARCH = (guildID) => `/guilds/${guildID}/messages/search`; module.exports.GUILD_PREVIEW = (guildID) => `/guilds/${guildID}/preview`; module.exports.GUILD_PRUNE = (guildID) => `/guilds/${guildID}/prune`; module.exports.GUILD_ROLE = (guildID, roleID) => `/guilds/${guildID}/roles/${roleID}`; @@ -98,7 +92,6 @@ module.exports.USER_GUILDS = (userID) module.exports.VOICE_REGIONS = "/voice/regions"; module.exports.WEBHOOK = (hookID) => `/webhooks/${hookID}`; module.exports.WEBHOOK_MESSAGE = (hookID, token, msgID) => `/webhooks/${hookID}/${token}/messages/${msgID}`; -module.exports.WEBHOOK_SLACK = (hookID) => `/webhooks/${hookID}/slack`; module.exports.WEBHOOK_TOKEN = (hookID, token) => `/webhooks/${hookID}/${token}`; module.exports.WEBHOOK_TOKEN_SLACK = (hookID, token) => `/webhooks/${hookID}/${token}/slack`; diff --git a/lib/rest/RequestHandler.js b/lib/rest/RequestHandler.js index a8b88d460..84b4a7357 100644 --- a/lib/rest/RequestHandler.js +++ b/lib/rest/RequestHandler.js @@ -16,22 +16,15 @@ const Zlib = require("zlib"); */ class RequestHandler { constructor(client, options) { - // [DEPRECATED] Previously forceQueueing - if(typeof options === "boolean") { - options = { - forceQueueing: options - }; - } this.options = options = Object.assign({ - agent: client.options.agent || null, + agent: null, baseURL: Endpoints.BASE_URL, - decodeReasons: true, disableLatencyCompensation: false, domain: "discord.com", https: true, - latencyThreshold: client.options.latencyThreshold || 30000, - ratelimiterOffset: client.options.ratelimiterOffset || 0, - requestTimeout: client.options.requestTimeout || 15000 + latencyThreshold: 30000, + ratelimiterOffset: 0, + requestTimeout: 15000 }, options); this._client = client; @@ -92,17 +85,7 @@ class RequestHandler { headers.Authorization = this._client._token; } if(body && body.reason) { // Audit log reason sniping - let unencodedReason = body.reason; - if(this.options.decodeReasons) { - try { - if(unencodedReason.includes("%") && !unencodedReason.includes(" ")) { - unencodedReason = decodeURIComponent(unencodedReason); - } - } catch(err) { - this._client.emit("error", err); - } - } - headers["X-Audit-Log-Reason"] = encodeURIComponent(unencodedReason); + headers["X-Audit-Log-Reason"] = encodeURIComponent(body.reason); delete body.reason; } diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 3f979b82e..66bb541d8 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -13,6 +13,7 @@ const GuildScheduledEvent = require("./GuildScheduledEvent"); const {Permissions} = require("../Constants"); const StageInstance = require("./StageInstance"); const ThreadChannel = require("./ThreadChannel"); +const emitDeprecation = require("../util/emitDeprecation"); /** * Represents a guild @@ -49,7 +50,6 @@ const ThreadChannel = require("./ThreadChannel"); * @prop {Number} memberCount Number of members in the guild * @prop {Collection} members Collection of Members in the guild * @prop {String} name The name of the guild -* @prop {Boolean} nsfw [DEPRECATED] Whether the guild is designated as NSFW by Discord * @prop {Number} nsfwLevel The guild NSFW level designated by Discord * @prop {String} ownerID The ID of the user that is the guild owner * @prop {String} preferredLocale Preferred "COMMUNITY" guild language used in server discovery and notices from Discord @@ -311,9 +311,6 @@ class Guild extends Base { }) }; } - if(data.nsfw !== undefined) { - this.nsfw = data.nsfw; - } if(data.nsfw_level !== undefined) { this.nsfwLevel = data.nsfw_level; } @@ -359,14 +356,12 @@ class Guild extends Base { /** * Ban a user from the guild * @arg {String} userID The ID of the member - * @arg {Number} [options.deleteMessageDays=0] [DEPRECATED] Number of days to delete messages for, between 0-7 inclusive * @arg {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604,800 inclusive * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs * @returns {Promise} */ - banMember(userID, options, reason) { - return this._client.banGuildMember.call(this._client, this.id, userID, options, reason); + banMember(userID, options) { + return this._client.banGuildMember.call(this._client, this.id, userID, options); } /** @@ -410,7 +405,7 @@ class Guild extends Base { * Create a channel in the guild * @arg {String} name The name of the channel * @arg {Number} [type=0] The type of the channel, either 0 (text), 2 (voice), 4 (category), 5 (news) or 13 (stage) - * @arg {Object | String} [options] The properties the channel should have. If `options` is a string, it will be treated as `options.parentID` (see below). Passing a string is deprecated and will not be supported in future versions. + * @arg {Object | String} [options] The properties the channel should have. * @arg {Number} [options.bitrate] The bitrate of the channel (voice channels only) * @arg {Boolean} [options.nsfw] The nsfw status of the channel * @arg {String?} [options.parentID] The ID of the parent category channel for this channel @@ -422,8 +417,8 @@ class Guild extends Base { * @arg {Number} [options.userLimit] The channel user limit (voice channels only) * @returns {Promise} */ - createChannel(name, type, reason, options) { - return this._client.createChannel.call(this._client, this.id, name, type, reason, options); + createChannel(name, type, options) { + return this._client.createChannel.call(this._client, this.id, name, type, options); } /** @@ -782,15 +777,6 @@ class Guild extends Base { return this._client.editGuildMember.call(this._client, this.id, memberID, options, reason); } - /** - * [DEPRECATED] Edit the bot's nickname in the guild - * @arg {String} nick The nickname - * @returns {Promise} - */ - editNickname(nick) { - return this._client.editNickname.call(this._client, this.id, nick); - } - /** * Edit the guild role * @arg {String} roleID The ID of the role @@ -905,11 +891,14 @@ class Guild extends Base { } /** - * Request all guild members from Discord + * [DEPRECATED] Request all guild members from Discord * @arg {Number} [timeout] The number of milliseconds to wait before resolving early. Defaults to the `requestTimeout` client option * @returns {Promise} Resolves with the total number of fetched members. */ fetchAllMembers(timeout) { + emitDeprecation("FETCH_ALL_MEMBERS"); + this._client.emit("warn", "[DEPRECATED] Guild#fetchAllMembers is deprecated. Use Guild#fetchMembers instead"); + return this.fetchMembers({ timeout }).then((m) => m.length); @@ -939,7 +928,7 @@ class Guild extends Base { /** * Get the audit log for the guild - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request. * @arg {Number} [options.actionType] Filter entries by action type * @arg {String} [options.before] Get entries before this entry ID * @arg {Number} [options.limit=50] The maximum number of entries to return @@ -950,18 +939,6 @@ class Guild extends Base { return this._client.getGuildAuditLog.call(this._client, this.id, options); } - /** - * [DEPRECATED] Get the audit log for a guild. Use `getAuditLog` instead - * @arg {Number} [limit=50] The maximum number of entries to return - * @arg {String} [before] Get entries before this entry ID - * @arg {Number} [actionType] Filter entries by action type - * @arg {String} [userID] Filter entries by the user that performed the action - * @returns {Promise<{entries: Array, integrations: Array, threads: Array, users: Array, webhooks: Array}>} - */ - getAuditLogs(limit, before, actionType, userID) { - return this._client.getGuildAuditLogs.call(this._client, this.id, limit, before, actionType, userID); - } - /** * Get an existing auto moderation rule * @arg {String} guildID The ID of the guild to get the rule from @@ -1110,14 +1087,13 @@ class Guild extends Base { /** * Get a guild's members via the REST API. REST mode is required to use this endpoint. - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request * @arg {String} [options.after] The highest user ID of the previous page * @arg {Number} [options.limit=1] The max number of members to get (1 to 1000) - * @arg {String} [after] [DEPRECATED] The highest user ID of the previous page * @returns {Promise>} */ - getRESTMembers(options, after) { - return this._client.getRESTGuildMembers.call(this._client, this.id, options, after); + getRESTMembers(options) { + return this._client.getRESTGuildMembers.call(this._client, this.id, options); } /** diff --git a/lib/structures/Member.js b/lib/structures/Member.js index 823fcd76b..e08393883 100644 --- a/lib/structures/Member.js +++ b/lib/structures/Member.js @@ -1,7 +1,6 @@ "use strict"; const Base = require("./Base"); -const emitDeprecation = require("../util/emitDeprecation"); const Endpoints = require("../rest/Endpoints"); const User = require("./User"); const VoiceState = require("./VoiceState"); @@ -34,7 +33,6 @@ const VoiceState = require("./VoiceState"); * @prop {String} mention A string that mentions the member * @prop {String?} nick The server nickname of the member * @prop {Boolean?} pending Whether the member has passed the guild's Membership Screening requirements -* @prop {Permission} permission [DEPRECATED] The guild-wide permissions of the member. Use Member#permissions instead * @prop {Permission} permissions The guild-wide permissions of the member * @prop {Number?} premiumSince Timestamp of when the member boosted the guild * @prop {Array} roles An array of role IDs this member is a part of @@ -160,12 +158,6 @@ class Member extends Base { return `<@!${this.id}>`; } - get permission() { - emitDeprecation("MEMBER_PERMISSION"); - this.guild.shard.client.emit("warn", "[DEPRECATED] Member#permission is deprecated. Use Member#permissions instead"); - return this.permissions; - } - get permissions() { return this.guild.permissionsOf(this); } @@ -204,14 +196,12 @@ class Member extends Base { /** * Ban the user from the guild - * @arg {Number} [options.deleteMessageDays=0] [DEPRECATED] Number of days to delete messages for, between 0-7 inclusive * @arg {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604,800 inclusive * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs * @returns {Promise} */ - ban(options, reason) { - return this.guild.shard.client.banGuildMember.call(this.guild.shard.client, this.guild.id, this.id, options, reason); + ban(options) { + return this.guild.shard.client.banGuildMember.call(this.guild.shard.client, this.guild.id, this.id, options); } /** diff --git a/lib/structures/Message.js b/lib/structures/Message.js index 794b791b9..581e7661b 100644 --- a/lib/structures/Message.js +++ b/lib/structures/Message.js @@ -45,7 +45,6 @@ const Collection = require("../util/Collection"); * @prop {Object} reactions An object containing the reactions on the message. Each key is a reaction emoji and each value is an object with properties `me` (Boolean) and `count` (Number) for that specific reaction emoji. * @prop {Message?} referencedMessage The message that was replied to. If undefined, message data was not received. If null, the message was deleted. * @prop {Array} roleMentions Array of mentioned roles' ids -* @prop {Array?} stickers [DEPRECATED] The stickers sent with the message * @prop {Array?} stickerItems The stickers sent with the message * @prop {Number} timestamp Timestamp of message creation * @prop {Boolean} tts Whether to play the message using TTS or not @@ -297,10 +296,6 @@ class Message extends Base { }); } - if(data.stickers !== undefined) { - this.stickers = data.stickers; - } - if(data.sticker_items !== undefined) { this.stickerItems = data.sticker_items.map((sticker) => { if(sticker.user) { @@ -483,18 +478,16 @@ class Message extends Base { /** * Get a list of users who reacted with a specific reaction * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior) + * @arg {Object} [options] Options for the request. * @arg {Number} [options.limit=100] The maximum number of users to get * @arg {String} [options.after] Get users after this user ID - * @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter - * @arg {String} [after] [DEPRECATED] Get users after this user ID * @returns {Promise>} */ - getReaction(reaction, options, before, after) { + getReaction(reaction, options) { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot have reactions"); } - return this._client.getMessageReaction.call(this._client, this.channel.id, this.id, reaction, options, before, after); + return this._client.getMessageReaction.call(this._client, this.channel.id, this.id, reaction, options); } /** @@ -575,7 +568,6 @@ class Message extends Base { "reactions", "referencedMesssage", "roleMentions", - "stickers", "stickerItems", "timestamp", "tts", diff --git a/lib/structures/PrivateChannel.js b/lib/structures/PrivateChannel.js index 86d62e994..7b541887c 100644 --- a/lib/structures/PrivateChannel.js +++ b/lib/structures/PrivateChannel.js @@ -2,7 +2,6 @@ const Channel = require("./Channel"); const Collection = require("../util/Collection"); -const emitDeprecation = require("../util/emitDeprecation"); const Message = require("./Message"); const {ChannelTypes} = require("../Constants"); const User = require("./User"); @@ -29,11 +28,10 @@ class PrivateChannel extends Channel { * Add a reaction to a message * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {String} [userID="@me"] The ID of the user to react as. Passing this parameter is deprecated and will not be supported in future versions. * @returns {Promise} */ - addMessageReaction(messageID, reaction, userID) { - return this.client.addMessageReaction.call(this.client, this.id, messageID, reaction, userID); + addMessageReaction(messageID, reaction) { + return this.client.addMessageReaction.call(this.client, this.id, messageID, reaction); } /** @@ -46,14 +44,12 @@ class PrivateChannel extends Channel { * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure * @arg {String} [content.content] A content string - * @arg {Object} [content.embed] An embed object. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Object} [content.messageReference] The message reference, used when replying to messages * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead * @arg {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send * @arg {Boolean} [content.tts] Set the message TTS flag * @arg {Object | Array} [file] A file object (or an Array of them) @@ -110,31 +106,26 @@ class PrivateChannel extends Channel { * Get a list of users who reacted with a specific reaction * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior) + * @arg {Object} [options] Options for the request. * @arg {Number} [options.limit=100] The maximum number of users to get - * @arg {String} [options.after] Get users after this user ID - * @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter - * @arg {String} [after] [DEPRECATED] Get users after this user ID + * @arg {String} [options.after] Get users after this user IDD * @returns {Promise>} */ - getMessageReaction(messageID, reaction, options, before, after) { - return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options, before, after); + getMessageReaction(messageID, reaction, options) { + return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options); } /** * Get a previous message in a text channel - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request. * @arg {String} [options.after] Get messages after this message ID * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) * @arg {String} [options.before] Get messages before this message ID * @arg {Number} [options.limit=50] The max number of messages to get - * @arg {String} [before] [DEPRECATED] Get messages before this message ID - * @arg {String} [after] [DEPRECATED] Get messages after this message ID - * @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100) * @returns {Promise>} */ - getMessages(options, before, after, around) { - return this.client.getMessages.call(this.client, this.id, options, before, after, around); + getMessages(options) { + return this.client.getMessages.call(this.client, this.id, options); } /** @@ -166,15 +157,10 @@ class PrivateChannel extends Channel { * Remove a reaction from a message * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {String} [userID="@me"] The ID of the user to remove the reaction for. Passing this parameter is deprecated and will not be supported in future versions. * @returns {Promise} */ - removeMessageReaction(messageID, reaction, userID) { - if(userID !== undefined) { - emitDeprecation("DM_REACTION_BEFORE"); - this.emit("warn", "[DEPRECATED] removeMessageReaction() was called on a PrivateChannel with a `userID` argument"); - } - return this.client.removeMessageReaction.call(this.client, this.id, messageID, reaction, userID); + removeMessageReaction(messageID, reaction) { + return this.client.removeMessageReaction.call(this.client, this.id, messageID, reaction); } /** diff --git a/lib/structures/TextChannel.js b/lib/structures/TextChannel.js index 1d2a35c86..dbf93849f 100644 --- a/lib/structures/TextChannel.js +++ b/lib/structures/TextChannel.js @@ -84,14 +84,12 @@ class TextChannel extends GuildChannel { * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure * @arg {String} [content.content] A content string - * @arg {Object} [content.embed] An embed object. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Object} [content.messageReference] The message reference, used when replying to messages * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead * @arg {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send * @arg {Boolean} [content.tts] Set the message TTS flag * @arg {Object | Array} [file] A file object (or an Array of them) @@ -226,31 +224,26 @@ class TextChannel extends GuildChannel { * Get a list of users who reacted with a specific reaction * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior) + * @arg {Object} [options] Options for the request. * @arg {Number} [options.limit=100] The maximum number of users to get * @arg {String} [options.after] Get users after this user ID - * @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter - * @arg {String} [after] [DEPRECATED] Get users after this user ID * @returns {Promise>} */ - getMessageReaction(messageID, reaction, options, before, after) { - return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options, before, after); + getMessageReaction(messageID, reaction, options) { + return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options); } /** * Get previous messages in the channel - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request. * @arg {String} [options.after] Get messages after this message ID * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) * @arg {String} [options.before] Get messages before this message ID * @arg {Number} [options.limit=50] The max number of messages to get - * @arg {String} [before] [DEPRECATED] Get messages before this message ID - * @arg {String} [after] [DEPRECATED] Get messages after this message ID - * @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100) * @returns {Promise>} */ - getMessages(options, before, after, around) { - return this.client.getMessages.call(this.client, this.id, options, before, after, around); + getMessages(options) { + return this.client.getMessages.call(this.client, this.id, options); } /** @@ -280,20 +273,16 @@ class TextChannel extends GuildChannel { /** * Purge previous messages in the channel with an optional filter (bot accounts only) - * @arg {Object} options Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} options Options for the request * @arg {String} [options.after] Get messages after this message ID * @arg {String} [options.before] Get messages before this message ID * @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object * @arg {Number} options.limit The max number of messages to search through, -1 for no limit * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Function} [filter] [DEPRECATED] Optional filter function that returns a boolean when passed a Message object - * @arg {String} [before] [DEPRECATED] Get messages before this message ID - * @arg {String} [after] [DEPRECATED] Get messages after this message ID - * @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs * @returns {Promise} Resolves with the number of messages deleted */ - purge(limit, filter, before, after, reason) { - return this.client.purgeChannel.call(this.client, this.id, limit, filter, before, after, reason); + purge(limit, options) { + return this.client.purgeChannel.call(this.client, this.id, limit, options); } /** diff --git a/lib/structures/TextVoiceChannel.js b/lib/structures/TextVoiceChannel.js index 59f2bdb79..3048d3474 100644 --- a/lib/structures/TextVoiceChannel.js +++ b/lib/structures/TextVoiceChannel.js @@ -41,11 +41,10 @@ class TextVoiceChannel extends VoiceChannel { * Add a reaction to a message * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {String} [userID="@me"] The ID of the user to react as. Passing this parameter is deprecated and will not be supported in future versions. * @returns {Promise} */ - addMessageReaction(messageID, reaction, userID) { - return this.client.addMessageReaction.call(this.client, this.id, messageID, reaction, userID); + addMessageReaction(messageID, reaction) { + return this.client.addMessageReaction.call(this.client, this.id, messageID, reaction); } /** @@ -73,14 +72,12 @@ class TextVoiceChannel extends VoiceChannel { * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure * @arg {String} content.content A content string - * @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Object} [content.messageReference] The message reference, used when replying to messages * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead * @arg {Array} [content.stickerIDs] An array of IDs corresponding to the stickers to send * @arg {Boolean} [content.tts] Set the message TTS flag * @arg {Object} [file] A file object @@ -123,7 +120,6 @@ class TextVoiceChannel extends VoiceChannel { * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure * @arg {String} content.content A content string * @arg {Boolean} [content.disableEveryone] Whether to filter @everyone/@here or not (overrides default) - * @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference * @returns {Promise} @@ -153,49 +149,40 @@ class TextVoiceChannel extends VoiceChannel { * Get a list of users who reacted with a specific reaction * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior) + * @arg {Object} [options] Options for the request. * @arg {Number} [options.limit=100] The maximum number of users to get * @arg {String} [options.after] Get users after this user ID - * @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter - * @arg {String} [after] [DEPRECATED] Get users after this user ID * @returns {Promise>} */ - getMessageReaction(messageID, reaction, options, before, after) { - return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options, before, after); + getMessageReaction(messageID, reaction, options) { + return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options); } /** * Get previous messages in the channel - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request. * @arg {String} [options.after] Get messages after this message ID * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) * @arg {String} [options.before] Get messages before this message ID * @arg {Number} [options.limit=50] The max number of messages to get - * @arg {String} [before] [DEPRECATED] Get messages before this message ID - * @arg {String} [after] [DEPRECATED] Get messages after this message ID - * @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100) * @returns {Promise>} */ - getMessages(options, before, after, around) { - return this.client.getMessages.call(this.client, this.id, options, before, after, around); + getMessages(options) { + return this.client.getMessages.call(this.client, this.id, options); } /** * Purge previous messages in the channel with an optional filter (bot accounts only) - * @arg {Object} options Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} options Options for the request. * @arg {String} [options.after] Get messages after this message ID * @arg {String} [options.before] Get messages before this message ID * @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object * @arg {Number} options.limit The max number of messages to search through, -1 for no limit * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Function} [filter] [DEPRECATED] Optional filter function that returns a boolean when passed a Message object - * @arg {String} [before] [DEPRECATED] Get messages before this message ID - * @arg {String} [after] [DEPRECATED] Get messages after this message ID - * @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs * @returns {Promise} Resolves with the number of messages deleted */ - purge(limit, filter, before, after, reason) { - return this.client.purgeChannel.call(this.client, this.id, limit, filter, before, after, reason); + purge(limit, options) { + return this.client.purgeChannel.call(this.client, this.id, limit, options); } /** diff --git a/lib/structures/ThreadChannel.js b/lib/structures/ThreadChannel.js index 03b617c2f..619d070bb 100644 --- a/lib/structures/ThreadChannel.js +++ b/lib/structures/ThreadChannel.js @@ -88,7 +88,6 @@ class ThreadChannel extends GuildChannel { * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead * @arg {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send * @arg {Boolean} [content.tts] Set the message TTS flag * @arg {Object | Array} [file] A file object (or an Array of them) @@ -163,31 +162,26 @@ class ThreadChannel extends GuildChannel { * Get a list of users who reacted with a specific reaction * @arg {String} messageID The ID of the message * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior) + * @arg {Object} [options] Options for the request. * @arg {Number} [options.limit=100] The maximum number of users to get * @arg {String} [options.after] Get users after this user ID - * @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter - * @arg {String} [after] [DEPRECATED] Get users after this user ID * @returns {Promise>} */ - getMessageReaction(messageID, reaction, options, before, after) { - return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options, before, after); + getMessageReaction(messageID, reaction, options) { + return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options); } /** * Get previous messages in the channel - * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit` + * @arg {Object} [options] Options for the request. * @arg {String} [options.after] Get messages after this message ID * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) * @arg {String} [options.before] Get messages before this message ID * @arg {Number} [options.limit=50] The max number of messages to get - * @arg {String} [before] [DEPRECATED] Get messages before this message ID - * @arg {String} [after] [DEPRECATED] Get messages after this message ID - * @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100) * @returns {Promise>} */ - getMessages(options, before, after, around) { - return this.client.getMessages.call(this.client, this.id, options, before, after, around); + getMessages(options) { + return this.client.getMessages.call(this.client, this.id, options); } /** diff --git a/lib/util/emitDeprecation.js b/lib/util/emitDeprecation.js index 993fb22d3..2c9a597af 100644 --- a/lib/util/emitDeprecation.js +++ b/lib/util/emitDeprecation.js @@ -1,10 +1,5 @@ const warningMessages = { - CREATE_CHANNEL_OPTIONS: "Passing parentID or reason string arguments directly to createChannel() is deprecated. Use an options object instead.", - DM_REACTION_REMOVE: "Passing a userID when using removeMessageReaction() in a PrivateChannel is deprecated. This behavior is no longer supported by Discord.", - GET_REACTION_BEFORE: "Passing the before parameter to getMessageReaction() is deprecated. Discord no longer supports this parameter.", - MEMBER_PERMISSION: "Member#permission is deprecated. Use Member#permissions instead.", - MESSAGE_REFERENCE: "Passing the content.messageReferenceID option to createMessage() is deprecated. Use the content.messageReference option instead.", - REACTION_USER: "Passing a userID other than \"@me\" to addMessageReaction() is deprecated. Discord no longer supports this parameter." + FETCH_ALL_MEMBERS: "Fetching all guild members via fetchAllMembers() is deprecated. Use Guild#fetchMembers instead." }; const unknownCodeMessage = "You have triggered a deprecated behavior whose warning was implemented improperly. Please report this issue."; diff --git a/lib/voice/VoiceConnection.js b/lib/voice/VoiceConnection.js index 1f782624a..885fb516d 100644 --- a/lib/voice/VoiceConnection.js +++ b/lib/voice/VoiceConnection.js @@ -829,10 +829,6 @@ class VoiceConnection extends EventEmitter { } } - // [DEPRECATED] - _sendAudioPacket(audio) { - return this._sendAudioFrame(audio); - } [util.inspect.custom]() { return Base.prototype[util.inspect.custom].call(this);