Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ForumChannels): Support Forum Channels #1452

Merged
merged 85 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
e499899
Prepare for forums
conorwastakenwastaken Apr 26, 2023
e1189e1
Support creating/editing channels with forum props
conorwastakenwastaken May 8, 2023
fc24222
Consistency & lint fixes
conorwastakenwastaken May 8, 2023
4eb9916
Add channel type 15
conorwastakenwastaken May 8, 2023
fb82f6e
Typings
conorwastakenwastaken May 8, 2023
7eec4f8
channelUpdate support
conorwastakenwastaken May 8, 2023
a6f1764
Add applied_tags and flags
conorwastakenwastaken May 8, 2023
53cdc7c
Add rateLimitPerUser option
conorwastakenwastaken May 8, 2023
1f944f5
Add ForumChannel docs and functions
conorwastakenwastaken May 8, 2023
a4341e2
Merge remote-tracking branch 'upstream/dev' into forum-channels
conorwastakenwastaken Jan 25, 2024
ef24e41
createChannel/editChannel props
conorwastakenwastaken Jan 25, 2024
5dc265c
createThreadWith/WithoutMessage props
conorwastakenwastaken Jan 25, 2024
a06f6f4
Move flags to GuildChannel struc
conorwastakenwastaken Jan 25, 2024
ec211c2
Add `totalMessagesSent`
conorwastakenwastaken Jan 25, 2024
acbafc9
Update json
conorwastakenwastaken Jan 25, 2024
02ba11e
Fix missing properties
conorwastakenwastaken Jan 25, 2024
f2e4466
Fix jsdoc
conorwastakenwastaken Jan 25, 2024
1148a22
Update `messageCount` and `totalMessagesSent`
conorwastakenwastaken Jan 25, 2024
02e7d91
Add props to `CHANNEL_UPDATE` & update docs
conorwastakenwastaken Jan 25, 2024
61b23df
i cant read simple english
conorwastakenwastaken Jan 25, 2024
34dd13d
Moved to GuildChannel
conorwastakenwastaken Jan 25, 2024
36970e4
Fix
conorwastakenwastaken Jan 25, 2024
e60d418
Remove unused funcs
conorwastakenwastaken Jan 25, 2024
4db8707
Add `createThread`
conorwastakenwastaken Jan 25, 2024
a72fa16
Deprecate `createThreadWithoutMessage`
conorwastakenwastaken Jan 25, 2024
637b566
JS doc consistency
conorwastakenwastaken Jan 25, 2024
906ff6d
Order alphabetically
conorwastakenwastaken Jan 26, 2024
94cdbe4
Add new fields to THREAD_UPDATE
conorwastakenwastaken Jan 26, 2024
8cf237b
Fix `type` type
conorwastakenwastaken Jan 26, 2024
26ba105
Alphabetize (again)
conorwastakenwastaken Jan 26, 2024
2e88630
Remove accidentally added props
conorwastakenwastaken Jan 26, 2024
f13c30f
TextChannel#createThread()
conorwastakenwastaken Jan 26, 2024
a77cd64
Fix fix fix
conorwastakenwastaken Jan 26, 2024
e89cb4a
Specify all types
conorwastakenwastaken Jan 26, 2024
b5ce3b7
Consistency
conorwastakenwastaken Jan 26, 2024
fc2ca29
update json
conorwastakenwastaken Jan 26, 2024
5d798e1
add more stuff to json :flushed:
conorwastakenwastaken Jan 26, 2024
8110505
Forums can only have public threads
conorwastakenwastaken Jan 26, 2024
b63906f
Clean up typings
bsian03 Jan 27, 2024
806524c
Merge remote-tracking branch 'upstream/dev' into forum-channels
conorwastakenwastaken Jan 29, 2024
898a0e8
Fix
conorwastakenwastaken Jan 29, 2024
c34b7eb
Sort alphabetically
conorwastakenwastaken Jan 29, 2024
5078b67
Merge branch 'forum-channels' of https://github.com/iiFDCT/eris into …
conorwastakenwastaken Jan 29, 2024
e3391a9
Fix
conorwastakenwastaken Jan 29, 2024
6d1c928
Add ForumChannel & alphabetize
conorwastakenwastaken Jan 29, 2024
1ae9f69
Merge branch 'forum-channels' of https://github.com/iiFDCT/eris into …
conorwastakenwastaken Jan 29, 2024
e40ce2f
Update Shard.js
conorwastakenwastaken Jan 29, 2024
db3852a
Revert
conorwastakenwastaken Jan 29, 2024
a8f5416
Revert
conorwastakenwastaken Jan 29, 2024
3687944
Merge remote-tracking branch 'upstream/dev' into forum-channels
conorwastakenwastaken Feb 1, 2024
47a0ba2
Fix
conorwastakenwastaken Feb 1, 2024
98edc9c
TSDocs
conorwastakenwastaken Feb 1, 2024
d179333
Fix
conorwastakenwastaken Feb 4, 2024
92c134f
Del invalid options from ForumChannel.createThread
conorwastakenwastaken Feb 4, 2024
d0b8d3b
Match ddocs
conorwastakenwastaken Feb 4, 2024
d810263
Use .get(...)
conorwastakenwastaken Feb 4, 2024
23158a7
Only apply to forum channels
conorwastakenwastaken Feb 4, 2024
8751621
Document in PublicThreadChannel
conorwastakenwastaken Feb 4, 2024
e62dddf
MEGA SUPER EMERGENCY FIX
conorwastakenwastaken Feb 4, 2024
3b40682
Fix last message ID handling
bsian03 Feb 4, 2024
4da2c4a
Add docs ref link
conorwastakenwastaken Feb 6, 2024
a5b0bdb
Add deprecation warn
conorwastakenwastaken Feb 6, 2024
3ea7d03
Fix fix fix
conorwastakenwastaken Feb 6, 2024
8965aca
Apply suggestions from code review
conorwastakenwastaken Feb 6, 2024
9e6b15a
Add ForumChannel#threads
conorwastakenwastaken Feb 6, 2024
4aebe05
Fix
conorwastakenwastaken Feb 6, 2024
ebf5b0f
Merge branch 'forum-channels' of https://github.com/iiFDCT/eris into …
conorwastakenwastaken Feb 6, 2024
292ce02
Update Client.js
conorwastakenwastaken Feb 6, 2024
2400316
Merge branch 'dev' into forum-channels
conorwastakenwastaken Feb 6, 2024
89bc900
Fix updating PrivateThreadChannel parent class
bsian03 Feb 6, 2024
bdba9c0
Not optional
conorwastakenwastaken Feb 6, 2024
34db4d5
`totalMessagesSent` > `totalMessageSent`
conorwastakenwastaken Feb 6, 2024
1321221
Fix tsdoc typo
conorwastakenwastaken Feb 6, 2024
4e372c8
conor did a silly
bsian03 Feb 6, 2024
4c9033d
Jump over type `14`
conorwastakenwastaken Feb 7, 2024
3dcf5d7
Move to `THREAD_UPDATE`
conorwastakenwastaken Feb 7, 2024
39e01c3
Optional
conorwastakenwastaken Feb 7, 2024
8d82ca9
Fix
conorwastakenwastaken Feb 7, 2024
bd2b22f
Remove type param
conorwastakenwastaken Feb 7, 2024
0128850
appliedTags optional
conorwastakenwastaken Feb 7, 2024
47f39eb
move appliedtags to public thread
conorwastakenwastaken Feb 7, 2024
f2548c8
Add ForumChannel to ChannelTypeConversion
conorwastakenwastaken Feb 7, 2024
27fba6b
Omit type
conorwastakenwastaken Feb 7, 2024
9a823ca
spent way too long on this
conorwastakenwastaken Feb 7, 2024
7e02283
Improved typings for PublicThreadChannel
bsian03 Feb 7, 2024
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
1 change: 1 addition & 0 deletions esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const {
DiscordHTTPError,
DiscordRESTError,
ExtendedUser,
ForumChannel,
GroupChannel,
Guild,
GuildChannel,
Expand Down
110 changes: 97 additions & 13 deletions index.d.ts
conorwastakenwastaken marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,11 @@ declare namespace Eris {
type StickerFormats = Constants["StickerFormats"][keyof Constants["StickerFormats"]];
type StickerTypes = Constants["StickerTypes"][keyof Constants["StickerTypes"]];

// Thread
// Thread/Forum
type AutoArchiveDuration = 60 | 1440 | 4320 | 10080;
type ChannelFlags = Constants["ChannelFlags"][keyof Constants["ChannelFlags"]];
type ForumLayoutTypes = Constants["ForumLayoutTypes"][keyof Constants["ForumLayoutTypes"]];
type SortOrderTypes = Constants["SortOrderTypes"][keyof Constants["SortOrderTypes"]];

// User
type PremiumTypes = Constants["PremiumTypes"][keyof Constants["PremiumTypes"]];
Expand Down Expand Up @@ -347,6 +350,7 @@ declare namespace Eris {
/** valid for KEYWORD_PRESET */
presets: AutoModerationKeywordPresetType[];
}

// Channel
interface ChannelFollow {
channel_id: string;
Expand All @@ -359,7 +363,13 @@ declare namespace Eris {
position: number;
}
interface CreateChannelOptions {
availableTags?: ForumTag[];
bitrate?: number;
defaultAutoArchiveDuration?: AutoArchiveDuration;
defaultForumLayout?: ForumLayoutTypes;
defaultReactionEmoji?: DefaultReactionEmoji;
defaultSortOrder?: SortOrderTypes;
defaultThreadRateLimitPerUser?: number;
nsfw?: boolean;
parentID?: string;
permissionOverwrites?: Overwrite[];
Expand All @@ -370,9 +380,16 @@ declare namespace Eris {
userLimit?: number;
}
interface EditChannelOptions extends Omit<CreateChannelOptions, "reason"> {
appliedTags?: string[];
archived?: boolean;
autoArchiveDuration?: AutoArchiveDuration;
availableTags?: ForumTag[];
defaultAutoArchiveDuration?: AutoArchiveDuration;
defaultForumLayout?: ForumLayoutTypes;
defaultReactionEmoji?: DefaultReactionEmoji;
defaultSortOrder?: SortOrderTypes;
defaultThreadRateLimitPerUser?: number;
flags?: number;
icon?: string;
invitable?: boolean;
locked?: boolean;
Expand Down Expand Up @@ -673,6 +690,14 @@ declare namespace Eris {
ringing: string[];
unavailable: boolean;
}
interface OldForumChannel extends OldGuildChannel {
availableTags: ForumTag[];
defaultAutoArchiveDuration: AutoArchiveDuration;
defaultForumLayout: ForumLayoutTypes;
defaultReactionEmoji: DefaultReactionEmoji;
defaultSortOrder: SortOrderTypes;
defaultThreadRateLimitPerUser: number;
}
interface OldGroupChannel {
icon: string;
name: string;
Expand Down Expand Up @@ -720,6 +745,7 @@ declare namespace Eris {
}
interface OldGuildChannel {
bitrate?: number;
flags?: number;
name: string;
nsfw?: boolean;
parentID: string | null;
Expand Down Expand Up @@ -796,6 +822,8 @@ declare namespace Eris {
videoQualityMode: VideoQualityMode;
}
interface OldThread {
appliedTags: string[];
autoArchiveDuration: number;
name: string;
rateLimitPerUser: number;
threadMetadata: ThreadMetadata;
Expand Down Expand Up @@ -826,7 +854,7 @@ declare namespace Eris {
channelPinUpdate: [channel: TextableChannel, timestamp: number, oldTimestamp: number];
channelRecipientAdd: [channel: GroupChannel, user: User];
channelRecipientRemove: [channel: GroupChannel, user: User];
channelUpdate: [channel: AnyGuildChannel, oldChannel: OldGuildChannel | OldGuildTextChannel | OldVoiceChannel]
channelUpdate: [channel: AnyGuildChannel, oldChannel: OldGuildChannel | OldForumChannel | OldGuildTextChannel | OldVoiceChannel]
| [channel: GroupChannel, oldChannel: OldGroupChannel];
connect: [id: number];
debug: [message: string, id?: number];
Expand Down Expand Up @@ -1626,14 +1654,29 @@ declare namespace Eris {
guild_connections?: true;
}

// Thread
// Forum/Thread
interface CreateThreadOptions {
autoArchiveDuration: AutoArchiveDuration;
autoArchiveDuration?: AutoArchiveDuration;
name: string;
rateLimitPerUser?: number;
reason?: string;
}
interface CreateForumThreadOptions extends CreateThreadWithoutMessageOptions {
conorwastakenwastaken marked this conversation as resolved.
Show resolved Hide resolved
appliedTags?: string[];
message: Omit<AdvancedMessageContent, "messageReference" | "messageReferenceID" | "tts"> & FileContent[];
}
interface CreateThreadWithoutMessageOptions<T = AnyThreadChannel["type"]> extends CreateThreadOptions {
invitable: T extends PrivateThreadChannel["type"] ? boolean : never;
type: T;
invitable?: T extends PrivateThreadChannel["type"] ? boolean : never;
type?: T;
}
interface DefaultReactionEmoji {
emoji_id?: string;
emoji_name?: string;
}
interface ForumTag extends DefaultReactionEmoji {
id: string;
name: string;
moderated: boolean;
}
interface GetArchivedThreadsOptions {
before?: Date;
Expand Down Expand Up @@ -1912,6 +1955,10 @@ declare namespace Eris {
DANGER: 4;
LINK: 5;
};
ChannelFlags: {
PINNED: 1,
REQUIRE_TAG: 16
},
ChannelTypes: {
GUILD_TEXT: 0;
DM: 1;
Expand All @@ -1926,6 +1973,8 @@ declare namespace Eris {
GUILD_STAGE_VOICE: 13;
/** @deprecated */
GUILD_STAGE: 13;

GUILD_FORUM: 15;
conorwastakenwastaken marked this conversation as resolved.
Show resolved Hide resolved
};
ComponentTypes: {
ACTION_ROW: 1;
Expand All @@ -1937,10 +1986,19 @@ declare namespace Eris {
NONE: 0;
EVERYONE: 1;
};
ForumLayoutTypes: {
NOT_SET: 0,
LIST_VIEW: 1,
GALLERY_VIEW: 2
};
DefaultMessageNotificationLevels: {
ALL_MESSAGES: 0;
ONLY_MENTIONS: 1;
};
SortOrderTypes: {
LATEST_ACTIVITY: 0,
CREATION_DATE: 1
};
ExplicitContentFilterLevels: {
DISABLED: 0;
MEMBERS_WITHOUT_ROLES: 1;
Expand Down Expand Up @@ -2645,7 +2703,7 @@ declare namespace Eris {
): Promise<Invite<"withoutCount">>;
createChannelWebhook(
channelID: string,
options: { name: string; avatar?: string | null },
options: WebhookCreateOptions,
reason?: string
): Promise<Webhook>;
createCommand<T extends ApplicationCommandTypes>(command: ApplicationCommandCreateOptions<false, T>): Promise<ApplicationCommand<false, T>>;
Expand All @@ -2661,8 +2719,10 @@ declare namespace Eris {
createMessage(channelID: string, content: MessageContent, file?: FileContent | FileContent[]): Promise<Message>;
createRole(guildID: string, options?: Role | RoleOptions, reason?: string): Promise<Role>;
createStageInstance(channelID: string, options: StageInstanceOptions): Promise<StageInstance>;
createThread(channelID: string, options: CreateForumThreadOptions, file?: FileContent | FileContent[]): Promise<NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>;
bsian03 marked this conversation as resolved.
Show resolved Hide resolved
createThreadWithMessage(channelID: string, messageID: string, options: CreateThreadOptions): Promise<NewsThreadChannel | PublicThreadChannel>;
createThreadWithoutMessage(channelID: string, options: CreateThreadWithoutMessageOptions): Promise<PrivateThreadChannel>;
/** @deprecated */
createThreadWithoutMessage(channelID: string, options: CreateThreadWithoutMessageOptions): Promise<NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>;
crosspostMessage(channelID: string, messageID: string): Promise<Message>;
deleteAutoModerationRule(guildID: string, ruleID: string, reason?: string): Promise<void>;
deleteChannel(channelID: string, reason?: string): Promise<void>;
Expand Down Expand Up @@ -3029,6 +3089,25 @@ declare namespace Eris {
verified: boolean;
}

export class ForumChannel extends GuildChannel {
availableTags: ForumTag[];
defaultAutoArchiveDuration: AutoArchiveDuration;
defaultForumLayout: ForumLayoutTypes;
defaultReactionEmoji: DefaultReactionEmoji;
defaultSortOrder: SortOrderTypes;
defaultThreadRateLimitPerUser: number;
lastMessageID: string;
rateLimitPerUser: number;
threads: PublicThreadChannel[];
topic?: string;
createInvite(options?: CreateInviteOptions, reason?: string): Promise<Invite<"withMetadata", this>>;
createThread(options: CreateForumThreadOptions, file?: FileContent | FileContent[]): Promise<PublicThreadChannel>;
createWebhook(options: WebhookCreateOptions, reason?: string): Promise<Webhook>;
getArchivedThreads(type: "public", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PublicThreadChannel>>;
getInvites(): Promise<Invite<"withMetadata", this>[]>;
getWebhooks(): Promise<Webhook[]>;
}

export class GroupChannel extends PrivateChannel {
icon: string | null;
iconURL: string | null;
Expand Down Expand Up @@ -3235,6 +3314,7 @@ declare namespace Eris {
export class GuildChannel extends Channel {
guild: Guild;
name: string;
flags?: number;
parentID: string | null;
permissionOverwrites: Collection<PermissionOverwrite>;
position: number;
Expand Down Expand Up @@ -3606,7 +3686,7 @@ declare namespace Eris {
crosspostMessage(messageID: string): Promise<Message<this>>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<this>>;
follow(webhookChannelID: string): Promise<ChannelFollow>;
getInvites(): Promise<(Invite<"withMetadata", this>)[]>;
getInvites(): Promise<Invite<"withMetadata", this>[]>;
getMessage(messageID: string): Promise<Message<this>>;
getMessages(options?: GetMessagesOptions): Promise<Message<this>[]>;
/** @deprecated */
Expand Down Expand Up @@ -3896,16 +3976,18 @@ declare namespace Eris {
addMessageReaction(messageID: string, reaction: string, userID: string): Promise<void>;
createInvite(options?: CreateInviteOptions, reason?: string): Promise<Invite<"withMetadata", this>>;
createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise<Message<this>>;
createThreadWithMessage(messageID: string, options: CreateThreadOptions): Promise<PublicThreadChannel>;
createThreadWithoutMessage(options: CreateThreadWithoutMessageOptions): Promise<PrivateThreadChannel>;
createThread(options: CreateThreadWithoutMessageOptions): Promise<NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>;
createThreadWithMessage(messageID: string, options: CreateThreadOptions): Promise<NewsThreadChannel | PublicThreadChannel>;
/** @deprecated */
createThreadWithoutMessage(options: CreateThreadWithoutMessageOptions): Promise<NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>;
createWebhook(options: WebhookCreateOptions, reason?: string): Promise<Webhook>;
deleteMessage(messageID: string, reason?: string): Promise<void>;
deleteMessages(messageIDs: string[], reason?: string): Promise<void>;
edit(options: Omit<EditChannelOptions, "icon" | "ownerID">, reason?: string): Promise<this>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<this>>;
getArchivedThreads(type: "private", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PrivateThreadChannel>>;
getArchivedThreads(type: "public", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PublicThreadChannel>>;
getInvites(): Promise<(Invite<"withMetadata", this>)[]>;
getInvites(): Promise<Invite<"withMetadata", this>[]>;
getJoinedPrivateArchivedThreads(options: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PrivateThreadChannel>>;
getMessage(messageID: string): Promise<Message<this>>;
getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise<User[]>;
Expand Down Expand Up @@ -3960,6 +4042,7 @@ declare namespace Eris {
}

export class ThreadChannel extends GuildChannel implements ThreadTextable {
appliedTags: string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you move this to public thread channel, create a generic which checks if the public thread channel belongs in a forum channel or not (we should specify where necessary if it does)

lastMessageID: string;
lastPinTimestamp?: number;
member?: ThreadMember;
Expand All @@ -3970,6 +4053,7 @@ declare namespace Eris {
ownerID: string;
rateLimitPerUser: number;
threadMetadata: ThreadMetadata;
totalMessageSent: number;
type: GuildThreadChannelTypes;
constructor(data: BaseData, client: Client, messageLimit?: number);
addMessageReaction(messageID: string, reaction: string): Promise<void>;
Expand Down Expand Up @@ -4054,7 +4138,7 @@ declare namespace Eris {
type: GuildVoiceChannelTypes;
voiceMembers: Collection<Member>;
createInvite(options?: CreateInviteOptions, reason?: string): Promise<Invite<"withMetadata", VoiceChannel>>;
getInvites(): Promise<(Invite<"withMetadata", VoiceChannel>)[]>;
getInvites(): Promise<Invite<"withMetadata", VoiceChannel>[]>;
join(options?: JoinVoiceChannelOptions): Promise<VoiceConnection>;
leave(): void;
}
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Eris.Constants = require("./lib/Constants");
Eris.DiscordHTTPError = require("./lib/errors/DiscordHTTPError");
Eris.DiscordRESTError = require("./lib/errors/DiscordRESTError");
Eris.ExtendedUser = require("./lib/structures/ExtendedUser");
Eris.ForumChannel = require("./lib/structures/ForumChannel");
Eris.GroupChannel = require("./lib/structures/GroupChannel");
Eris.Guild = require("./lib/structures/Guild");
Eris.GuildChannel = require("./lib/structures/GuildChannel");
Expand Down
Loading