Skip to content
Merged
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
57 changes: 57 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ declare namespace Eris {
type GuildWidgetStyles = Constants["GuildWidgetStyles"][keyof Constants["GuildWidgetStyles"]];
type MFALevel = Constants["MFALevels"][keyof Constants["MFALevels"]];
type NSFWLevel = Constants["GuildNSFWLevels"][keyof Constants["GuildNSFWLevels"]];
type OnboardingModes = Constants["GuildOnboardingModes"][keyof Constants["GuildOnboardingModes"]];
type OnboardingPromptTypes = Constants["GuildOnboardingPromptTypes"][keyof Constants["GuildOnboardingPromptTypes"]];
type PossiblyUncachedGuild = Guild | Uncached;
type PossiblyUncachedGuildScheduledEvent = GuildScheduledEvent | Uncached;
type PremiumTier = Constants["PremiumTiers"][keyof Constants["PremiumTiers"]];
Expand Down Expand Up @@ -1053,6 +1055,41 @@ declare namespace Eris {
reason?: string;
user: User;
}
interface GuildOnboarding {
default_channel_ids: string[];
enabled: boolean;
guild_id: string;
mode: OnboardingModes;
prompts: GuildOnboardingPrompt[];
}
interface GuildOnboardingOptions extends Omit<GuildOnboarding, "guild_id" | "prompt"> {
prompts: GuildOnboardingPromptOptions[];
}
interface GuildOnboardingPrompt {
id: string;
in_onboarding: boolean;
options: GuildOnboardingPromptOption[];
required: boolean;
single_select: boolean;
title: string;
type: OnboardingPromptTypes;
}
interface GuildOnboardingPromptOption {
channel_ids: string[];
description: string | null;
emoji?: PartialEmoji;
id: string;
role_ids: string[];
title: string;
}
interface GuildOnboardingPromptOptionOptions<T = boolean> extends Omit<GuildOnboardingPromptOption, "emoji"> {
emoji_animated: T extends true ? boolean : never;
emoji_id: T extends true ? string : never;
emoji_name: T extends true ? string : never;
}
interface GuildOnboardingPromptOptions extends Omit<GuildOnboardingPrompt, "options"> {
options: GuildOnboardingPromptOptionOptions[];
}
interface GuildOptions {
afkChannelID?: string | null;
afkTimeout?: number;
Expand Down Expand Up @@ -1299,6 +1336,7 @@ declare namespace Eris {
channelID?: string | null;
communicationDisabledUntil?: Date | null;
deaf?: boolean;
flags?: number;
mute?: boolean;
nick?: string | null;
roles?: string[];
Expand Down Expand Up @@ -1952,6 +1990,14 @@ declare namespace Eris {
SAFE: 2;
AGE_RESTRICTED: 3;
};
GuildOnboardingModes: {
ONBOARDING_DEFAULT: 0;
ONBOARDING_ADVANCED: 1;
}
GuildOnboardingPromptTypes: {
MULTIPLE_CHOICE: 0;
DROPDOWN: 1;
}
GuildScheduledEventEntityTypes: {
STAGE_INSTANCE: 1;
VOICE: 2;
Expand Down Expand Up @@ -2031,6 +2077,12 @@ declare namespace Eris {
STREAM: 1;
EMBEDDED_APPLICATION: 2;
};
MemberFlags: {
DID_REJOIN: 1;
COMPLETED_ONBOARDING: 2;
BYPASSES_VERIFICATION: 4;
STARTED_ONBOARDING: 8;
}
MessageActivityTypes: {
JOIN: 1;
SPECTATE: 2;
Expand Down Expand Up @@ -2645,6 +2697,7 @@ declare namespace Eris {
editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise<void>;
editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise<Member>;
editGuildMFALevel(guildID: string, level: MFALevel, reason?: string): Promise<MFALevelResponse>;
editGuildOnboarding(guildID: string, options: GuildOnboardingOptions, reason?: string): Promise<GuildOnboarding>;
editGuildScheduledEvent<T extends GuildScheduledEventEntityTypes>(guildID: string, eventID: string, event: GuildScheduledEventEditOptions<T>, reason?: string): Promise<GuildScheduledEvent<T>>;
editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise<Sticker>;
editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise<GuildTemplate>;
Expand Down Expand Up @@ -2720,6 +2773,7 @@ declare namespace Eris {
getGuildEmbed(guildID: string): Promise<Widget>;
getGuildIntegrations(guildID: string): Promise<GuildIntegration[]>;
getGuildInvites(guildID: string): Promise<Invite[]>;
getGuildOnboarding(guildID: string): Promise<GuildOnboarding>;
getGuildPreview(guildID: string): Promise<GuildPreview>;
getGuildScheduledEvents(guildID: string, options?: GetGuildScheduledEventOptions): Promise<GuildScheduledEvent[]>
getGuildScheduledEventUsers(guildID: string, eventID: string, options?: GetGuildScheduledEventUsersOptions): Promise<GuildScheduledEventUser[]>;
Expand Down Expand Up @@ -3074,6 +3128,7 @@ declare namespace Eris {
editMFALevel(level: MFALevel, reason?: string): Promise<MFALevelResponse>;
/** @deprecated */
editNickname(nick: string): Promise<void>;
editOnboarding(options: GuildOnboardingOptions, reason?: string): Promise<GuildOnboarding>;
editRole(roleID: string, options: RoleOptions): Promise<Role>;
editScheduledEvent<T extends GuildScheduledEventEntityTypes>(eventID: string, event: GuildScheduledEventEditOptions<T>, reason?: string): Promise<GuildScheduledEvent<T>>
editSticker(stickerID: string, options?: EditStickerOptions, reason?: string): Promise<Sticker>;
Expand All @@ -3100,6 +3155,7 @@ declare namespace Eris {
getEmbed(): Promise<Widget>;
getIntegrations(): Promise<GuildIntegration>;
getInvites(): Promise<Invite[]>;
getOnboarding(): Promise<GuildOnboarding>;
getPruneCount(options?: GetPruneOptions): Promise<number>;
getRESTChannels(): Promise<AnyGuildChannel[]>;
getRESTEmoji(emojiID: string): Promise<Emoji>;
Expand Down Expand Up @@ -3408,6 +3464,7 @@ declare namespace Eris {
defaultAvatar: string;
defaultAvatarURL: string;
discriminator: string;
flags: number;
game: Activity | null;
globalName: string | null;
guild: Guild;
Expand Down
28 changes: 28 additions & 0 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,7 @@ class Client extends EventEmitter {
* @arg {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member
* @arg {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout
* @arg {Boolean} [options.deaf] Server deafen the member
* @arg {Number} [options.flags] The user's flags - `OR` the `BYPASSES_VERIFICATION` flag (4) to make the member exempt from verification requirements, `NAND` the flag to make the member not exempt
* @arg {Boolean} [options.mute] Server mute the member
* @arg {String} [options.nick] Set the member's server nickname, "" to remove
* @arg {Array<String>} [options.roles] The array of role IDs the member should have
Expand All @@ -1780,6 +1781,7 @@ class Client extends EventEmitter {
deaf: options.deaf,
channel_id: options.channelID,
communication_disabled_until: options.communicationDisabledUntil,
flags: options.flags,
reason: reason
}).then((member) => new Member(member, this.guilds.get(guildID), this));
}
Expand All @@ -1798,6 +1800,23 @@ class Client extends EventEmitter {
});
}

/**
* Edit a guild's onboarding settings
* @arg {String} guildID The ID of the guild
* @arg {Object} options The properties to edit
* @arg {Array<String>} options.defaultChannelIDs The ID of channels that members are opted into automatically
* @arg {Boolean} options.enabled Whether onboarding should be enabled or not for the guild
* @arg {Number} options.mode The onboarding mode, `0` for default, `1` for advanced
* @arg {Array<Object>} options.prompts The [prompts](https://discord.dev/resources/guild#guild-onboarding-object-onboarding-prompt-structure) shown during the onboarding process
* @arg {String} [reason] The reason to be displayed in audit logs
* @returns {Promise<Object>} The guild's [onboarding settings](https://discord.dev/resources/guild#guild-onboarding-object)
*/
editGuildOnboarding(guildID, options, reason) {
options.default_channel_ids = options.defaultChannelIDs;
options.reason = reason;
return this.requestHandler.request("PATCH", Endpoints.GUILD_ONBOARDING(guildID), true, options);
}

/**
* Edit a guild scheduled event
* @arg {String} guildID The guild ID where the event will be edited
Expand Down Expand Up @@ -2756,6 +2775,15 @@ class Client extends EventEmitter {
return this.requestHandler.request("GET", Endpoints.GUILD_INVITES(guildID), true).then((invites) => invites.map((invite) => new Invite(invite, this)));
}

/**
* Get a guild's onboarding settings
* @arg {String} guildID The ID of the guild
* @returns {Promise<Object>} The guild's [onboarding settings](https://discord.dev/resources/guild#guild-onboarding-object)
*/
getGuildOnboarding(guildID) {
return this.requestHandler.request("GET", Endpoints.GUILD_ONBOARDING(guildID), true);
}

/**
* Get a guild preview for a guild. Only available for community guilds.
* @arg {String} guildID The ID of the guild
Expand Down
17 changes: 17 additions & 0 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ module.exports.GuildNSFWLevels = {
AGE_RESTRICTED: 3
};

module.exports.GuildOnboardingModes = {
ONBOARDING_DEFAULT: 0,
ONBOARDING_ADVANCED: 1
};

module.exports.GuildOnboardingPromptTypes = {
MULTIPLE_CHOICE: 0,
DROPDOWN: 1
};

module.exports.GuildScheduledEventEntityTypes = {
STAGE_INSTANCE: 1,
VOICE: 2,
Expand Down Expand Up @@ -373,6 +383,13 @@ module.exports.InviteTargetTypes = {
EMBEDDED_APPLICATION: 2
};

module.exports.MemberFlags = {
DID_REJOIN: 1 << 0,
COMPLETED_ONBOARDING: 1 << 1,
BYPASSES_VERIFICATION: 1 << 2,
STARTED_ONBOARDING: 1 << 3
};

module.exports.MembershipState = {
INVITED: 1,
ACCEPTED: 2
Expand Down
1 change: 1 addition & 0 deletions lib/rest/Endpoints.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ class Guild extends Base {
* @arg {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member
* @arg {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout
* @arg {Boolean} [options.deaf] Server deafen the member
* @arg {Number} [options.flags] The user's flags - `OR` the `BYPASSES_VERIFICATION` flag (4) to make the member exempt from verification requirements, `NAND` the flag to make the member not exempt
* @arg {Boolean} [options.mute] Server mute the member
* @arg {String} [options.nick] Set the member's guild nickname, "" to remove
* @arg {Array<String>} [options.roles] The array of role IDs the member should have
Expand Down Expand Up @@ -846,6 +847,20 @@ class Guild extends Base {
return this._client.editNickname.call(this._client, this.id, nick);
}

/**
* Edit the guild's onboarding settings
* @arg {Object} options The properties to edit
* @arg {Array<String>} options.defaultChannelIDs The ID of channels that members are opted into automatically
* @arg {Boolean} options.enabled Whether onboarding should be enabled or not for the guild
* @arg {Number} options.mode The onboarding mode, `0` for default, `1` for advanced
* @arg {Array<Object>} options.prompts The [prompts](https://discord.dev/resources/guild#guild-onboarding-object-onboarding-prompt-structure) shown during the onboarding process
* @arg {String} [reason] The reason to be displayed in audit logs
* @returns {Promise<Object>} The guild's [onboarding settings](https://discord.dev/resources/guild#guild-onboarding-object)
*/
editOnboarding(options, reason) {
return this._client.editGuildOnboarding.call(this._client, this.id, options, reason);
}

/**
* Edit the guild role
* @arg {String} roleID The ID of the role
Expand Down Expand Up @@ -1118,6 +1133,14 @@ class Guild extends Base {
return this._client.getGuildInvites.call(this._client, this.id);
}

/**
* Get the guild's onboarding settings
* @returns {Promise<Object>} The guild's [onboarding settings](https://discord.dev/resources/guild#guild-onboarding-object)
*/
getOnboarding() {
return this._client.getGuildOnboarding.call(this._client, this.id);
}

/**
* Get the prune count for the guild
* @arg {Number} [options] The options to use to get number of prune members
Expand Down
5 changes: 5 additions & 0 deletions lib/structures/Member.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const VoiceState = require("./VoiceState");
* @prop {String} defaultAvatar The hash for the default avatar of a user if there is no avatar set
* @prop {String} defaultAvatarURL The URL of the user's default avatar
* @prop {String} discriminator The discriminator of the user. If they've migrated to the new username system, this will be "0"
* @prop {Number} flags The member's flags (see Constants)
* @prop {Object?} game The active game the member is playing
* @prop {String} game.name The name of the active game
* @prop {Number} game.type The type of the active game (0 is default, 1 is Twitch, 2 is YouTube)
Expand Down Expand Up @@ -119,6 +120,9 @@ class Member extends Base {
this.communicationDisabledUntil = data.communication_disabled_until;
}
}
if(data.flags !== undefined) {
this.flags = data.flags;
}
}

get accentColor() {
Expand Down Expand Up @@ -238,6 +242,7 @@ class Member extends Base {
* @arg {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member
* @arg {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout
* @arg {Boolean} [options.deaf] Server deafen the user
* @arg {Number} [options.flags] The user's flags - `OR` the `BYPASSES_VERIFICATION` flag (4) to make the member exempt from verification requirements, `NAND` the flag to make the member not exempt
* @arg {Boolean} [options.mute] Server mute the user
* @arg {String} [options.nick] Set the user's server nickname, "" to remove
* @arg {Array<String>} [options.roles] The array of role IDs the user should have
Expand Down