Skip to content

Commit

Permalink
Guild Scheduled Events (#1275)
Browse files Browse the repository at this point in the history
Co-authored-by: Bsian <[email protected]>
Co-authored-by: HeadTriXz <[email protected]>
Co-authored-by: Donovan Daniels <[email protected]>
  • Loading branch information
4 people authored Nov 18, 2022
1 parent eb40373 commit 3e62ca7
Show file tree
Hide file tree
Showing 13 changed files with 670 additions and 18 deletions.
1 change: 1 addition & 0 deletions esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const {
GuildChannel,
GuildIntegration,
GuildPreview,
GuildScheduledEvent,
GuildTemplate,
Interaction,
Invite,
Expand Down
133 changes: 131 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ declare namespace Eris {
type GuildTextableChannel = TextChannel | TextVoiceChannel | NewsChannel;
type GuildTextableWithThread = GuildTextableChannel | AnyThreadChannel;
type InviteChannel = InvitePartialChannel | Exclude<AnyGuildChannel, CategoryChannel | AnyThreadChannel>;
type PossiblyUncachedSpeakableChannel = VoiceChannel | StageChannel | Uncached;
type PossiblyUncachedTextable = Textable | Uncached;
type PossiblyUncachedTextableChannel = TextableChannel | Uncached;
type TextableChannel = (GuildTextable & GuildTextableChannel) | (ThreadTextable & AnyThreadChannel) | (Textable & PrivateChannel);
Expand Down Expand Up @@ -87,8 +88,14 @@ declare namespace Eris {
type DefaultNotifications = Constants["DefaultMessageNotificationLevels"][keyof Constants["DefaultMessageNotificationLevels"]];
type ExplicitContentFilter = Constants["ExplicitContentFilterLevels"][keyof Constants["ExplicitContentFilterLevels"]];
type GuildFeatures = Constants["GuildFeatures"][number];
type GuildScheduledEventEditOptions<T extends GuildScheduledEventEntityTypes> = GuildScheduledEventEditOptionsExternal | GuildScheduledEventEditOptionsDiscord | GuildScheduledEventEditOptionsBase<T>;
type GuildScheduledEventOptions<T extends GuildScheduledEventEntityTypes> = GuildScheduledEventOptionsExternal | GuildScheduledEventOptionsDiscord | GuildScheduledEventOptionsBase<T>;
type GuildScheduledEventEntityTypes = Constants["GuildScheduledEventEntityTypes"][keyof Constants["GuildScheduledEventEntityTypes"]];
type GuildScheduledEventPrivacyLevel = Constants["GuildScheduledEventPrivacyLevel"][keyof Constants["GuildScheduledEventPrivacyLevel"]];
type GuildScheduledEventStatus = Constants["GuildScheduledEventStatus"][keyof Constants["GuildScheduledEventStatus"]];
type NSFWLevel = Constants["GuildNSFWLevels"][keyof Constants["GuildNSFWLevels"]];
type PossiblyUncachedGuild = Guild | Uncached;
type PossiblyUncachedGuildScheduledEvent = GuildScheduledEvent | Uncached;
type PremiumTier = Constants["PremiumTiers"][keyof Constants["PremiumTiers"]];
type VerificationLevel = Constants["VerificationLevels"][keyof Constants["VerificationLevels"]];
type SystemChannelFlags = Constants["SystemChannelFlags"][keyof Constants["SystemChannelFlags"]];
Expand Down Expand Up @@ -627,6 +634,19 @@ declare namespace Eris {
topic?: string | null;
type: GuildChannelTypes;
}
interface OldGuildScheduledEvent {
channel: PossiblyUncachedSpeakableChannel | null;
description?: string | null;
entityID: string | null;
enitityMetadata: GuildScheduledEventMetadata | null;
entityType: GuildScheduledEventEntityTypes;
image?: string;
name: string;
privacyLevel: GuildScheduledEventPrivacyLevel;
scheduledEndTime: number | null;
scheduledStartTime: number;
status: GuildScheduledEventStatus;
}
interface OldGuildTextChannel extends OldGuildChannel {
nsfw: boolean;
rateLimitPerUser: number;
Expand Down Expand Up @@ -724,6 +744,11 @@ declare namespace Eris {
guildRoleCreate: [guild: Guild, role: Role];
guildRoleDelete: [guild: Guild, role: Role];
guildRoleUpdate: [guild: Guild, role: Role, oldRole: OldRole];
guildScheduledEventCreate: [event: GuildScheduledEvent];
guildScheduledEventDelete: [event: GuildScheduledEvent];
guildScheduledEventUpdate: [event: GuildScheduledEvent, oldEvent: OldGuildScheduledEvent | null];
guildScheduledEventUserAdd: [event: PossiblyUncachedGuildScheduledEvent, user: User | Uncached];
guildScheduledEventUserRemove: [event: PossiblyUncachedGuildScheduledEvent, user: User | Uncached];
guildStickersUpdate: [guild: PossiblyUncachedGuild, stickers: Sticker[], oldStickers: Sticker[] | null];
guildUnavailable: [guild: UnavailableGuild];
guildUpdate: [guild: Guild, oldGuild: OldGuild];
Expand Down Expand Up @@ -883,6 +908,15 @@ declare namespace Eris {
before?: string;
limit?: number;
}
interface GetGuildScheduledEventOptions {
withUserCount?: boolean;
}
interface GetGuildScheduledEventUsersOptions {
after?: string;
before?: string;
limit?: number;
withMember?: boolean;
}
interface GetPruneOptions {
days?: number;
includeRoles?: string[];
Expand Down Expand Up @@ -927,6 +961,52 @@ declare namespace Eris {
systemChannelID?: string;
verificationLevel?: VerificationLevel;
}
interface GuildScheduledEventMetadata {
location?: string;
}
interface GuildScheduledEventEditOptionsBase<T extends GuildScheduledEventEntityTypes = GuildScheduledEventEntityTypes> {
channelID?: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? null : string;
description?: string | null;
entityMetadata?: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required<GuildScheduledEventMetadata> : GuildScheduledEventMetadata | null;
entityType?: T;
image?: string;
name?: string;
privacyLevel?: GuildScheduledEventPrivacyLevel;
scheduledEndTime?: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Date : Date | undefined;
scheduledStartTime?: Date;
status?: GuildScheduledEventStatus;
}
interface GuildScheduledEventEditOptionsDiscord extends GuildScheduledEventEditOptionsBase<Exclude<GuildScheduledEventEntityTypes, Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"]>> {
channelID: string;
entityMetadata: GuildScheduledEventMetadata;
}
interface GuildScheduledEventEditOptionsExternal extends GuildScheduledEventEditOptionsBase<Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"]> {
channelID: null;
enitityMetadata: Required<GuildScheduledEventMetadata>;
scheduledEndTime: Date;
}
interface GuildScheduledEventOptionsBase<T extends GuildScheduledEventEntityTypes> extends Omit<GuildScheduledEventEditOptionsBase<T>, "entityMetadata" | "status"> {
channelID: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? never : string;
entityMetadata?: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required<GuildScheduledEventMetadata> : GuildScheduledEventMetadata | undefined;
entityType: T;
name: string;
privacyLevel: GuildScheduledEventPrivacyLevel;
scheduledStartTime: Date;
}
interface GuildScheduledEventOptionsDiscord extends GuildScheduledEventEditOptionsBase<Exclude<GuildScheduledEventEntityTypes, Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"]>> {
channelID: string;
entityMetadata: GuildScheduledEventMetadata;
}
interface GuildScheduledEventOptionsExternal extends GuildScheduledEventOptionsBase<Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"]> {
channelID: never;
enitityMetadata: Required<GuildScheduledEventMetadata>;
scheduledEndTime: Date;
}
interface GuildScheduledEventUser {
guildScheduledEventID: string;
user: User;
member?: Member;
}
interface GuildTemplateOptions {
name?: string;
description?: string | null;
Expand Down Expand Up @@ -1698,9 +1778,10 @@ declare namespace Eris {
directMessages: 4096;
directMessageReactions: 8192;
directMessageTyping: 16384;
allNonPrivileged: 32509;
guildScheduledEvents: 65536;
allNonPrivileged: 98045;
allPrivileged: 258;
all: 32767;
all: 98303;
};
InteractionResponseTypes: {
PONG: 1;
Expand Down Expand Up @@ -1948,6 +2029,21 @@ declare namespace Eris {
/** @deprecated */
DISCONNECT: 13;
};
GuildScheduledEventStatus: {
SCHEDULED: 1;
ACTIVE: 2;
COMPLETED: 3;
CANCELED: 4;
};
GuildScheduledEventEntityTypes: {
STAGE_INSTANCE: 1;
VOICE: 2;
EXTERNAL: 3;
};
GuildScheduledEventPrivacyLevel: {
PUBLIC: 1;
GUILD_ONLY: 2;
};
WebhookTypes: {
INCOMING: 1;
CHANNEL_FOLLOWER: 2;
Expand Down Expand Up @@ -2261,6 +2357,7 @@ declare namespace Eris {
createGuildCommand(guildID: string, command: ApplicationCommandStructure): Promise<ApplicationCommand>;
createGuildEmoji(guildID: string, options: EmojiOptions, reason?: string): Promise<Emoji>;
createGuildFromTemplate(code: string, name: string, icon?: string): Promise<Guild>;
createGuildScheduledEvent<T extends GuildScheduledEventEntityTypes>(guildID: string, event: GuildScheduledEventOptions<T>, reason?: string): Promise<GuildScheduledEvent<T>>;
createGuildSticker(guildID: string, options: CreateStickerOptions, reason?: string): Promise<Sticker>;
createGuildTemplate(guildID: string, name: string, description?: string | null): Promise<GuildTemplate>;
createInteractionResponse(interactionID: string, interactionToken: string, options: InteractionOptions, file?: FileContent | FileContent[]): Promise<void>;
Expand All @@ -2279,6 +2376,7 @@ declare namespace Eris {
deleteGuildDiscoverySubcategory(guildID: string, categoryID: string, reason?: string): Promise<void>;
deleteGuildEmoji(guildID: string, emojiID: string, reason?: string): Promise<void>;
deleteGuildIntegration(guildID: string, integrationID: string): Promise<void>;
deleteGuildScheduledEvent(guildID: string, eventID: string): Promise<void>;
deleteGuildSticker(guildID: string, stickerID: string, reason?: string): Promise<void>;
deleteGuildTemplate(guildID: string, code: string): Promise<GuildTemplate>;
deleteInvite(inviteID: string, reason?: string): Promise<void>;
Expand Down Expand Up @@ -2322,6 +2420,7 @@ declare namespace Eris {
): Promise<Emoji>;
editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise<void>;
editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise<Member>;
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>;
editGuildVanity(guildID: string, code: string | null): Promise<GuildVanity>;
Expand Down Expand Up @@ -2397,6 +2496,8 @@ declare namespace Eris {
getGuildIntegrations(guildID: string): Promise<GuildIntegration[]>;
getGuildInvites(guildID: string): Promise<Invite[]>;
getGuildPreview(guildID: string): Promise<GuildPreview>;
getGuildScheduledEvents(guildID: string, options?: GetGuildScheduledEventOptions): Promise<GuildScheduledEvent[]>
getGuildScheduledEventUsers(guildID: string, eventID: string, options?: GetGuildScheduledEventUsersOptions): Promise<GuildScheduledEventUser[]>;
getGuildTemplate(code: string): Promise<GuildTemplate>;
getGuildTemplates(guildID: string): Promise<GuildTemplate[]>;
getGuildVanity(guildID: string): Promise<GuildVanity>;
Expand Down Expand Up @@ -2431,6 +2532,7 @@ declare namespace Eris {
getRESTGuilds(options?: GetRESTGuildsOptions): Promise<Guild[]>;
/** @deprecated */
getRESTGuilds(limit?: number, before?: string, after?: string): Promise<Guild[]>;
getRESTGuildScheduledEvent(guildID: string, eventID: string, options?: GetGuildScheduledEventOptions): Promise<GuildScheduledEvent>;
getRESTGuildSticker(guildID: string, stickerID: string): Promise<Sticker>;
getRESTGuildStickers(guildID: string): Promise<Sticker[]>;
getRESTSticker(stickerID: string): Promise<Sticker>;
Expand Down Expand Up @@ -2655,6 +2757,7 @@ declare namespace Eris {
discoverySplashURL: string | null;
emojiCount?: number;
emojis: Emoji[];
events: Collection<GuildScheduledEvent>;
explicitContentFilter: ExplicitContentFilter;
features: GuildFeatures[];
icon: string | null;
Expand Down Expand Up @@ -2728,6 +2831,7 @@ declare namespace Eris {
createEmoji(options: { image: string; name: string; roles?: string[] }, reason?: string): Promise<Emoji>;
createRole(options: RoleOptions, reason?: string): Promise<Role>;
createRole(options: Role, reason?: string): Promise<Role>;
createScheduledEvent<T extends GuildScheduledEventEntityTypes>(event: GuildScheduledEventOptions<T>, reason?: string): Promise<GuildScheduledEvent<T>>;
createSticker(options: CreateStickerOptions, reason?: string): Promise<Sticker>;
createTemplate(name: string, description?: string | null): Promise<GuildTemplate>;
delete(): Promise<void>;
Expand All @@ -2736,6 +2840,7 @@ declare namespace Eris {
deleteEmoji(emojiID: string, reason?: string): Promise<void>;
deleteIntegration(integrationID: string): Promise<void>;
deleteRole(roleID: string): Promise<void>;
deleteScheduledEvent(eventID: string): Promise<void>;
deleteSticker(stickerID: string, reason?: string): Promise<void>;
deleteTemplate(code: string): Promise<GuildTemplate>;
dynamicBannerURL(format?: ImageFormat, size?: number): string | null;
Expand All @@ -2753,6 +2858,7 @@ declare namespace Eris {
/** @deprecated */
editNickname(nick: string): Promise<void>;
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>;
editTemplate(code: string, options: GuildTemplateOptions): Promise<GuildTemplate>;
editVanity(code: string | null): Promise<GuildVanity>;
Expand Down Expand Up @@ -2784,8 +2890,11 @@ declare namespace Eris {
/** @deprecated */
getRESTMembers(limit?: number, after?: string): Promise<Member[]>;
getRESTRoles(): Promise<Role[]>;
getRESTScheduledEvent(eventID: string): Promise<GuildScheduledEvent>;
getRESTSticker(stickerID: string): Promise<Sticker>;
getRESTStickers(): Promise<Sticker[]>;
getScheduledEvents(options?: GetGuildScheduledEventOptions): Promise<GuildScheduledEvent[]>;
getScheduledEventUsers(eventID: string, options?: GetGuildScheduledEventUsersOptions): Promise<GuildScheduledEventUser[]>;
getTemplates(): Promise<GuildTemplate[]>;
getVanity(): Promise<GuildVanity>;
getVoiceRegions(): Promise<VoiceRegion[]>;
Expand Down Expand Up @@ -2849,6 +2958,26 @@ declare namespace Eris {
permissionsOf(memberID: string | Member | MemberRoles): Permission;
}

export class GuildScheduledEvent<T extends GuildScheduledEventEntityTypes = GuildScheduledEventEntityTypes> extends Base {
channelID: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? null : PossiblyUncachedSpeakableChannel;
creator?: User;
description?: string;
entityID: string | null;
entityMetadata: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? Required<GuildScheduledEventMetadata> : null;
entityType: T;
guild: PossiblyUncachedGuild;
id: string;
image?: string;
name: string;
privacyLevel: GuildScheduledEventPrivacyLevel;
scheduledEndTime: T extends Constants["GuildScheduledEventEntityTypes"]["EXTERNAL"] ? number : number | null;
scheduledStartTime: number;
status: GuildScheduledEventStatus;
userCount?: number;
delete(): Promise<void>;
edit<U extends GuildScheduledEventEntityTypes>(event: GuildScheduledEventEditOptions<U>, reason?: string): Promise<GuildScheduledEvent<U>>;
getUsers(options?: GetGuildScheduledEventUsersOptions): Promise<GuildScheduledEventUser[]>;
}

export class GuildIntegration extends Base {
account: { id: string; name: string };
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Eris.Guild = require("./lib/structures/Guild");
Eris.GuildChannel = require("./lib/structures/GuildChannel");
Eris.GuildIntegration = require("./lib/structures/GuildIntegration");
Eris.GuildPreview = require("./lib/structures/GuildPreview");
Eris.GuildScheduledEvent = require("./lib/structures/GuildScheduledEvent");
Eris.GuildTemplate = require("./lib/structures/GuildTemplate");
Eris.Interaction = require("./lib/structures/Interaction");
Eris.Invite = require("./lib/structures/Invite");
Expand Down
Loading

0 comments on commit 3e62ca7

Please sign in to comment.