Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ declare namespace Eris {

// Invite
type InviteTargetTypes = Constants["InviteTargetTypes"][keyof Constants["InviteTargetTypes"]];
type InviteTypes = Constants["InviteTypes"][keyof Constants["InviteTypes"]];

// Message
type ActionRowComponents = Button | SelectMenu;
Expand Down Expand Up @@ -2353,8 +2354,12 @@ declare namespace Eris {
getGuildWidget(guildID: string): Promise<WidgetData>;
getGuildWidgetImageURL(guildID: string, style?: GuildWidgetStyles): string;
getGuildWidgetSettings(guildID: string): Promise<Widget>;
/** @deprecated */
getInvite(inviteID: string, withCounts?: false, withExpiration?: boolean, guildScheduledEventID?: string): Promise<Invite<"withoutCount">>;
/** @deprecated */
getInvite(inviteID: string, withCounts: true, withExpiration?: boolean, guildScheduledEventID?: string): Promise<Invite<"withCount">>;
getInvite(inviteID: string, withCounts?: false, guildScheduledEventID?: string): Promise<Invite<"withoutCount">>;
getInvite(inviteID: string, withCounts: true, guildScheduledEventID?: string): Promise<Invite<"withCount">>;
getJoinedPrivateArchivedThreads(channelID: string, options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PrivateThreadChannel>>;
getMessage(channelID: string, messageID: string): Promise<Message>;
getMessageReaction(channelID: string, messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise<User[]>;
Expand Down Expand Up @@ -3046,6 +3051,7 @@ declare namespace Eris {
// @ts-ignore: Property is only not null when invite metadata is supplied
createdAt: CT extends "withMetadata" ? number : null;
expiresAt?: CT extends "withCount" ? number | null : null;
flags?: number;
guild: CT extends "withMetadata"
? Guild // Invite with Metadata always has guild prop
: CH extends Extract<InviteChannel, GroupChannel> // Invite without Metadata
Expand All @@ -3062,6 +3068,7 @@ declare namespace Eris {
/** @deprecated */
stageInstance: CH extends StageChannel ? InviteStageInstance : null;
temporary: CT extends "withMetadata" ? boolean : null;
type: InviteTypes;
uses: CT extends "withMetadata" ? number : null;
constructor(data: BaseData, client: Client);
delete(reason?: string): Promise<void>;
Expand Down
10 changes: 7 additions & 3 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3019,14 +3019,18 @@ class Client extends EventEmitter {
* Get info on an invite
* @arg {String} inviteID The ID of the invite
* @arg {Boolean} [withCounts] Whether to fetch additional invite info or not (approximate member counts, approximate presences, channel counts, etc.)
* @arg {Boolean} [withExpiration] Whether to fetch the expiration time or not
* @arg {Boolean} [withExpiration] [DEPRECATED] Whether to fetch the expiration time or not. This is deprecated because Discord will now always return the expiration date
* @arg {String} [guildScheduledEventID] The guild scheduled event to include with the invite
* @returns {Promise<Invite>}
*/
getInvite(inviteID, withCounts, withExpiration, guildScheduledEventID) {
getInvite(inviteID, withCounts, _withExpiration, guildScheduledEventID) {
if (typeof _withExpiration === "string") {
guildScheduledEventID = _withExpiration;
} else if (typeof _withExpiration === "boolean") {
emitDeprecation("GET_INVITE_WITH_EXPIRATION");
}
return this.requestHandler.request("GET", Endpoints.INVITE(inviteID), true, {
with_counts: withCounts,
with_expiration: withExpiration,
guild_scheduled_event_id: guildScheduledEventID,
}).then((invite) => new Invite(invite, this));
}
Expand Down
9 changes: 9 additions & 0 deletions lib/Constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export default interface Constants {
"DEVELOPER_SUPPORT_SERVER",
"DISCOVERABLE",
"FEATURABLE",
"GUESTS_ENABLED",
"INVITES_DISABLED",
"INVITE_SPLASH",
"MEMBER_VERIFICATION_GATE_ENABLED",
Expand Down Expand Up @@ -357,10 +358,18 @@ export default interface Constants {
APPLICATION_COMMAND_AUTOCOMPLETE: 4;
MODAL_SUBMIT: 5;
};
InviteFlags: {
IS_GUEST_INVITE: 1;
};
InviteTargetTypes: {
STREAM: 1;
EMBEDDED_APPLICATION: 2;
};
InviteTypes: {
GUILD: 0;
GROUP_DM: 1;
FRIEND: 2;
};
Locales: {
BULGARIAN: "bg";
CZECH: "cs";
Expand Down
11 changes: 11 additions & 0 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ module.exports.GuildFeatures = [
"DEVELOPER_SUPPORT_SERVER",
"DISCOVERABLE",
"FEATURABLE",
"GUESTS_ENABLED",
"INVITE_SPLASH",
"INVITES_DISABLED",
"MEMBER_VERIFICATION_GATE_ENABLED",
Expand Down Expand Up @@ -436,11 +437,21 @@ module.exports.InteractionTypes = {
MODAL_SUBMIT: 5,
};

module.exports.InviteFlags = {
IS_GUEST_INVITE: 1 << 0,
};

module.exports.InviteTargetTypes = {
STREAM: 1,
EMBEDDED_APPLICATION: 2,
};

module.exports.InviteTypes = {
GUILD: 0,
GROUP_DM: 1,
FRIEND: 2,
};

module.exports.Locales = {
BULGARIAN: "bg",
CZECH: "cs",
Expand Down
9 changes: 9 additions & 0 deletions lib/structures/Invite.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Member = require("./Member");
* @prop {String} code The invite code
* @prop {Number?} createdAt Timestamp of invite creation
* @prop {Number?} expiresAt Timestamp of invite expiration
* @prop {Number?} flags The invite flags. For now, if there are any invite flags, they will only be `1` (meaning this invite is a guest invite for a voice channel)
* @prop {(Guild | Object)?} guild Info on the invite guild. If the guild is not cached, this will be an object with an `id` key. No other property is guaranteed.
* @prop {User?} inviter The invite creator
* @prop {Number?} maxAge How long the invite lasts in seconds
Expand All @@ -25,6 +26,7 @@ const Member = require("./Member");
* @prop {Number?} targetType The type of the target application
* @prop {User?} targetUser The user whose stream is displayed for the invite (voice channel only)
* @prop {Boolean?} temporary Whether the invite grants temporary membership or not
* @prop {Number} type The type of invite. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/invite#invite-object-invite-types) for valid types
* @prop {Number?} uses The number of invite uses
*/
class Invite extends Base {
Expand Down Expand Up @@ -71,6 +73,12 @@ class Invite extends Base {
} else {
this.stageInstance = null;
}
if (data.flags !== undefined) {
this.flags = data.flags;
}
if (data.type !== undefined) {
this.type = data.type;
}
this.targetApplicationID = data.target_application !== undefined ? data.target_application.id : null;
this.targetType = data.target_type !== undefined ? data.target_type : null;
this.targetUser = data.target_user !== undefined ? this._client.users.update(data.target_user, this._client) : null;
Expand Down Expand Up @@ -102,6 +110,7 @@ class Invite extends Base {
"channel",
"code",
"createdAt",
"flags",
"guild",
"maxAge",
"maxUses",
Expand Down
2 changes: 1 addition & 1 deletion lib/structures/Member.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const VoiceState = require("./VoiceState");
* @prop {String?} globalName The user's display name, if it is set. For bots, this is the application name
* @prop {Guild} guild The guild the member is in
* @prop {String} id The ID of the member
* @prop {Number?} joinedAt Timestamp of when the member joined the guild
* @prop {Number?} joinedAt Timestamp of when the member joined the guild (Note: Member objects retrieved from `Client#voiceStateUpdate` events will have `joinedAt` set as `null` if the member was invited as a guest)
* @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
Expand Down
1 change: 1 addition & 0 deletions lib/util/emitDeprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const warningMessages = {
DEFAULT_PERMISSION: "Passing a defaultPermission for application commands is deprecated. Use defaultMemberPermissions instead.",
DELETE_MESSAGE_DAYS: "Passing the deleteMessageDays parameter to banGuildMember is deprecated. Use an options object with deleteMessageSeconds instead.",
DM_REACTION_REMOVE: "Passing a userID when using removeMessageReaction() in a DMChannel is deprecated. This behavior is no longer supported by Discord.",
GET_INVITE_WITH_EXPIRATION: "Passing withExpiration to getInvite() is deprecated. This is because Discord now always sends an expiration date when fetching an invite.",
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.",
Expand Down