From 3bb42e3751763ff9ae2d7837c9b2e80862a25584 Mon Sep 17 00:00:00 2001 From: Jaron Date: Sat, 15 Feb 2025 11:03:11 -0600 Subject: [PATCH 01/20] Added aider to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9b1ee42..65137a5 100644 --- a/.gitignore +++ b/.gitignore @@ -173,3 +173,4 @@ dist # Finder (MacOS) folder config .DS_Store +.aider* From 1480905468398f8992afa069ff5d9b25c66d7075 Mon Sep 17 00:00:00 2001 From: "Jaron (aider)" Date: Sat, 15 Feb 2025 11:18:20 -0600 Subject: [PATCH 02/20] feat: Enhance Channel type with comprehensive Discord channel structure support --- src/types/channel.ts | 155 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 135 insertions(+), 20 deletions(-) diff --git a/src/types/channel.ts b/src/types/channel.ts index 5736741..9f329d1 100644 --- a/src/types/channel.ts +++ b/src/types/channel.ts @@ -1,39 +1,154 @@ -export class Channel { - version: number; - type: number; - position: number; - permission_overwrites: any[]; - name: string; +import { GatewayObject } from './base'; +import { User } from './user'; +import { Trait } from '../utils'; + +export enum ChannelType { + GUILD_TEXT = 0, + DM = 1, + GUILD_VOICE = 2, + GROUP_DM = 3, + GUILD_CATEGORY = 4, + GUILD_ANNOUNCEMENT = 5, + ANNOUNCEMENT_THREAD = 10, + PUBLIC_THREAD = 11, + PRIVATE_THREAD = 12, + GUILD_STAGE_VOICE = 13, + GUILD_DIRECTORY = 14, + GUILD_FORUM = 15, + GUILD_MEDIA = 16 +} + +export enum ChannelFlags { + PINNED = 1 << 1, + REQUIRE_TAG = 1 << 4, + HIDE_MEDIA_DOWNLOAD_OPTIONS = 1 << 15 +} + +export enum VideoQualityMode { + AUTO = 1, + FULL = 2 +} + +export enum SortOrderType { + LATEST_ACTIVITY = 0, + CREATION_DATE = 1 +} + +export enum ForumLayoutType { + NOT_SET = 0, + LIST_VIEW = 1, + GALLERY_VIEW = 2 +} + +export type PermissionOverwrite = { id: string; + type: 0 | 1; // 0 for role, 1 for member + allow: string; + deny: string; +} + +export type ThreadMetadata = { + archived: boolean; + auto_archive_duration: number; + archive_timestamp: string; + locked: boolean; + invitable?: boolean; + create_timestamp?: string | null; +} + +export type ThreadMember = { + id?: string; + user_id?: string; + join_timestamp: string; flags: number; +} + +export type ForumTag = { + id: string; + name: string; + moderated: boolean; + emoji_id?: string | null; + emoji_name?: string | null; +} + +export class Channel extends GatewayObject { + id: string; + type: ChannelType; + guild_id?: string; + position?: number; + permission_overwrites?: PermissionOverwrite[]; + name?: string; topic?: string | null; - rate_limit_per_user?: number; - parent_id?: string; + nsfw?: boolean; last_message_id?: string | null; - user_limit?: number; - rtc_region?: string | null; bitrate?: number; - last_pin_timestamp?: string; + user_limit?: number; + rate_limit_per_user?: number; + recipients?: User[]; + icon?: string | null; + owner_id?: string; + application_id?: string; + parent_id?: string | null; + last_pin_timestamp?: string | null; + rtc_region?: string | null; + video_quality_mode?: VideoQualityMode; + message_count?: number; + member_count?: number; + thread_metadata?: ThreadMetadata; + member?: ThreadMember; + default_auto_archive_duration?: number; + permissions?: string; + flags?: number; + total_message_sent?: number; + available_tags?: ForumTag[]; + applied_tags?: string[]; + default_reaction_emoji?: { + emoji_id?: string | null; + emoji_name?: string | null; + }; + default_thread_rate_limit_per_user?: number; + default_sort_order?: SortOrderType | null; + default_forum_layout?: ForumLayoutType; constructor(data: any) { - this.version = data.version; + super(); + this.id = data.id; this.type = data.type; + this.guild_id = data.guild_id; this.position = data.position; this.permission_overwrites = data.permission_overwrites; this.name = data.name; - this.id = data.id; - this.flags = data.flags; this.topic = data.topic; - this.rate_limit_per_user = data.rate_limit_per_user; - this.parent_id = data.parent_id; + this.nsfw = data.nsfw; this.last_message_id = data.last_message_id; - this.user_limit = data.user_limit; - this.rtc_region = data.rtc_region; this.bitrate = data.bitrate; + this.user_limit = data.user_limit; + this.rate_limit_per_user = data.rate_limit_per_user; + this.recipients = data.recipients?.map((u: any) => new User(u)); + this.icon = data.icon; + this.owner_id = data.owner_id; + this.application_id = data.application_id; + this.parent_id = data.parent_id; this.last_pin_timestamp = data.last_pin_timestamp; + this.rtc_region = data.rtc_region; + this.video_quality_mode = data.video_quality_mode; + this.message_count = data.message_count; + this.member_count = data.member_count; + this.thread_metadata = data.thread_metadata; + this.member = data.member; + this.default_auto_archive_duration = data.default_auto_archive_duration; + this.permissions = data.permissions; + this.flags = data.flags; + this.total_message_sent = data.total_message_sent; + this.available_tags = data.available_tags; + this.applied_tags = data.applied_tags; + this.default_reaction_emoji = data.default_reaction_emoji; + this.default_thread_rate_limit_per_user = data.default_thread_rate_limit_per_user; + this.default_sort_order = data.default_sort_order; + this.default_forum_layout = data.default_forum_layout; } - static fromAPIResponse(data: any): Channel { + static [Trait.fromDiscord](data: any): Channel { return new Channel(data); } -} \ No newline at end of file +} From 43f83a196479dde70993186333cc787abae30a73 Mon Sep 17 00:00:00 2001 From: Jaron Date: Sat, 15 Feb 2025 11:19:59 -0600 Subject: [PATCH 03/20] Fix import in channel class --- src/types/channel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/channel.ts b/src/types/channel.ts index 9f329d1..7866845 100644 --- a/src/types/channel.ts +++ b/src/types/channel.ts @@ -1,6 +1,6 @@ import { GatewayObject } from './base'; +import { Trait } from './common'; import { User } from './user'; -import { Trait } from '../utils'; export enum ChannelType { GUILD_TEXT = 0, From dbad7168e842650dc35d562305b7c484e471a938 Mon Sep 17 00:00:00 2001 From: "Jaron (aider)" Date: Sat, 15 Feb 2025 11:30:41 -0600 Subject: [PATCH 04/20] feat: Add Channel types with enums and Discord/library interfaces --- src/types/channel.ts | 232 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) diff --git a/src/types/channel.ts b/src/types/channel.ts index 7866845..1ab8ffa 100644 --- a/src/types/channel.ts +++ b/src/types/channel.ts @@ -152,3 +152,235 @@ export class Channel extends GatewayObject { return new Channel(data); } } +import { GatewayObject } from "./base"; +import { Trait } from "./common"; +import { User, type DiscordUser } from "./user"; + +export enum ChannelType { + GUILD_TEXT = 0, + DM = 1, + GUILD_VOICE = 2, + GROUP_DM = 3, + GUILD_CATEGORY = 4, + GUILD_ANNOUNCEMENT = 5, + ANNOUNCEMENT_THREAD = 10, + PUBLIC_THREAD = 11, + PRIVATE_THREAD = 12, + GUILD_STAGE_VOICE = 13, + GUILD_DIRECTORY = 14, + GUILD_FORUM = 15, + GUILD_MEDIA = 16 +} + +export enum VideoQualityMode { + AUTO = 1, + FULL = 2 +} + +export enum ForumLayoutType { + NOT_SET = 0, + LIST_VIEW = 1, + GALLERY_VIEW = 2 +} + +export enum SortOrderType { + LATEST_ACTIVITY = 0, + CREATION_DATE = 1 +} + +export class Channel extends GatewayObject { + id: string; + type: ChannelType; + guild_id?: string; + position?: number; + permission_overwrites?: PermissionOverwrite[]; + name?: string; + topic?: string | null; + nsfw?: boolean; + last_message_id?: string | null; + bitrate?: number; + user_limit?: number; + rate_limit_per_user?: number; + recipients?: User[]; + icon?: string | null; + owner_id?: string; + application_id?: string; + managed?: boolean; + parent_id?: string | null; + last_pin_timestamp?: Date | null; + rtc_region?: string | null; + video_quality_mode?: VideoQualityMode; + message_count?: number; + member_count?: number; + thread_metadata?: ThreadMetadata; + member?: ThreadMember; + default_auto_archive_duration?: number; + permissions?: string; + flags?: number; + total_message_sent?: number; + available_tags?: ForumTag[]; + applied_tags?: string[]; + default_reaction_emoji?: DefaultReaction; + default_thread_rate_limit_per_user?: number; + default_sort_order?: SortOrderType | null; + default_forum_layout?: ForumLayoutType; + + constructor(data: Partial) { + super(); + this.id = data.id!; + this.type = data.type!; + this.guild_id = data.guild_id; + this.position = data.position; + this.permission_overwrites = data.permission_overwrites; + this.name = data.name; + this.topic = data.topic; + this.nsfw = data.nsfw; + this.last_message_id = data.last_message_id; + this.bitrate = data.bitrate; + this.user_limit = data.user_limit; + this.rate_limit_per_user = data.rate_limit_per_user; + this.recipients = data.recipients; + this.icon = data.icon; + this.owner_id = data.owner_id; + this.application_id = data.application_id; + this.managed = data.managed; + this.parent_id = data.parent_id; + this.last_pin_timestamp = data.last_pin_timestamp ? new Date(data.last_pin_timestamp) : null; + this.rtc_region = data.rtc_region; + this.video_quality_mode = data.video_quality_mode; + this.message_count = data.message_count; + this.member_count = data.member_count; + this.thread_metadata = data.thread_metadata; + this.member = data.member; + this.default_auto_archive_duration = data.default_auto_archive_duration; + this.permissions = data.permissions; + this.flags = data.flags; + this.total_message_sent = data.total_message_sent; + this.available_tags = data.available_tags; + this.applied_tags = data.applied_tags; + this.default_reaction_emoji = data.default_reaction_emoji; + this.default_thread_rate_limit_per_user = data.default_thread_rate_limit_per_user; + this.default_sort_order = data.default_sort_order; + this.default_forum_layout = data.default_forum_layout; + } + + public static [Trait.fromDiscord](data: DiscordChannel): Channel { + return new Channel({ + id: data.id, + type: data.type, + guild_id: data.guild_id, + position: data.position, + permission_overwrites: data.permission_overwrites, + name: data.name, + topic: data.topic, + nsfw: data.nsfw, + last_message_id: data.last_message_id, + bitrate: data.bitrate, + user_limit: data.user_limit, + rate_limit_per_user: data.rate_limit_per_user, + recipients: data.recipients?.map(u => User.fromDiscord(u)), + icon: data.icon, + owner_id: data.owner_id, + application_id: data.application_id, + managed: data.managed, + parent_id: data.parent_id, + last_pin_timestamp: data.last_pin_timestamp, + rtc_region: data.rtc_region, + video_quality_mode: data.video_quality_mode, + message_count: data.message_count, + member_count: data.member_count, + thread_metadata: data.thread_metadata, + member: data.member, + default_auto_archive_duration: data.default_auto_archive_duration, + permissions: data.permissions, + flags: data.flags, + total_message_sent: data.total_message_sent, + available_tags: data.available_tags, + applied_tags: data.applied_tags, + default_reaction_emoji: data.default_reaction_emoji, + default_thread_rate_limit_per_user: data.default_thread_rate_limit_per_user, + default_sort_order: data.default_sort_order, + default_forum_layout: data.default_forum_layout + }); + } +} + +export class DiscordChannel { + id: string; + type: number; + guild_id?: string; + position?: number; + permission_overwrites?: PermissionOverwrite[]; + name?: string; + topic?: string | null; + nsfw?: boolean; + last_message_id?: string | null; + bitrate?: number; + user_limit?: number; + rate_limit_per_user?: number; + recipients?: DiscordUser[]; + icon?: string | null; + owner_id?: string; + application_id?: string; + managed?: boolean; + parent_id?: string | null; + last_pin_timestamp?: string | null; + rtc_region?: string | null; + video_quality_mode?: number; + message_count?: number; + member_count?: number; + thread_metadata?: ThreadMetadata; + member?: ThreadMember; + default_auto_archive_duration?: number; + permissions?: string; + flags?: number; + total_message_sent?: number; + available_tags?: ForumTag[]; + applied_tags?: string[]; + default_reaction_emoji?: DefaultReaction; + default_thread_rate_limit_per_user?: number; + default_sort_order?: number | null; + default_forum_layout?: number; + + constructor(data: any) { + this.id = data.id; + this.type = data.type; + this.guild_id = data.guild_id; + this.position = data.position; + this.permission_overwrites = data.permission_overwrites; + this.name = data.name; + this.topic = data.topic; + this.nsfw = data.nsfw; + this.last_message_id = data.last_message_id; + this.bitrate = data.bitrate; + this.user_limit = data.user_limit; + this.rate_limit_per_user = data.rate_limit_per_user; + this.recipients = data.recipients; + this.icon = data.icon; + this.owner_id = data.owner_id; + this.application_id = data.application_id; + this.managed = data.managed; + this.parent_id = data.parent_id; + this.last_pin_timestamp = data.last_pin_timestamp; + this.rtc_region = data.rtc_region; + this.video_quality_mode = data.video_quality_mode; + this.message_count = data.message_count; + this.member_count = data.member_count; + this.thread_metadata = data.thread_metadata; + this.member = data.member; + this.default_auto_archive_duration = data.default_auto_archive_duration; + this.permissions = data.permissions; + this.flags = data.flags; + this.total_message_sent = data.total_message_sent; + this.available_tags = data.available_tags; + this.applied_tags = data.applied_tags; + this.default_reaction_emoji = data.default_reaction_emoji; + this.default_thread_rate_limit_per_user = data.default_thread_rate_limit_per_user; + this.default_sort_order = data.default_sort_order; + this.default_forum_layout = data.default_forum_layout; + } + + static fromAPIResponse(data: any): DiscordChannel { + return new DiscordChannel(data); + } +} From 6f385a68e7fb0b7d360a7f17a63d163f8c1fa45c Mon Sep 17 00:00:00 2001 From: Jaron Date: Sat, 15 Feb 2025 11:32:25 -0600 Subject: [PATCH 05/20] reformat channel type --- src/types/channel.ts | 123 ++----------------------------------------- 1 file changed, 3 insertions(+), 120 deletions(-) diff --git a/src/types/channel.ts b/src/types/channel.ts index 1ab8ffa..1b3a612 100644 --- a/src/types/channel.ts +++ b/src/types/channel.ts @@ -1,6 +1,6 @@ -import { GatewayObject } from './base'; -import { Trait } from './common'; -import { User } from './user'; +import { GatewayObject } from "./base"; +import { Trait } from "./common"; +import { User, type DiscordUser } from "./user"; export enum ChannelType { GUILD_TEXT = 0, @@ -71,123 +71,6 @@ export type ForumTag = { emoji_name?: string | null; } -export class Channel extends GatewayObject { - id: string; - type: ChannelType; - guild_id?: string; - position?: number; - permission_overwrites?: PermissionOverwrite[]; - name?: string; - topic?: string | null; - nsfw?: boolean; - last_message_id?: string | null; - bitrate?: number; - user_limit?: number; - rate_limit_per_user?: number; - recipients?: User[]; - icon?: string | null; - owner_id?: string; - application_id?: string; - parent_id?: string | null; - last_pin_timestamp?: string | null; - rtc_region?: string | null; - video_quality_mode?: VideoQualityMode; - message_count?: number; - member_count?: number; - thread_metadata?: ThreadMetadata; - member?: ThreadMember; - default_auto_archive_duration?: number; - permissions?: string; - flags?: number; - total_message_sent?: number; - available_tags?: ForumTag[]; - applied_tags?: string[]; - default_reaction_emoji?: { - emoji_id?: string | null; - emoji_name?: string | null; - }; - default_thread_rate_limit_per_user?: number; - default_sort_order?: SortOrderType | null; - default_forum_layout?: ForumLayoutType; - - constructor(data: any) { - super(); - this.id = data.id; - this.type = data.type; - this.guild_id = data.guild_id; - this.position = data.position; - this.permission_overwrites = data.permission_overwrites; - this.name = data.name; - this.topic = data.topic; - this.nsfw = data.nsfw; - this.last_message_id = data.last_message_id; - this.bitrate = data.bitrate; - this.user_limit = data.user_limit; - this.rate_limit_per_user = data.rate_limit_per_user; - this.recipients = data.recipients?.map((u: any) => new User(u)); - this.icon = data.icon; - this.owner_id = data.owner_id; - this.application_id = data.application_id; - this.parent_id = data.parent_id; - this.last_pin_timestamp = data.last_pin_timestamp; - this.rtc_region = data.rtc_region; - this.video_quality_mode = data.video_quality_mode; - this.message_count = data.message_count; - this.member_count = data.member_count; - this.thread_metadata = data.thread_metadata; - this.member = data.member; - this.default_auto_archive_duration = data.default_auto_archive_duration; - this.permissions = data.permissions; - this.flags = data.flags; - this.total_message_sent = data.total_message_sent; - this.available_tags = data.available_tags; - this.applied_tags = data.applied_tags; - this.default_reaction_emoji = data.default_reaction_emoji; - this.default_thread_rate_limit_per_user = data.default_thread_rate_limit_per_user; - this.default_sort_order = data.default_sort_order; - this.default_forum_layout = data.default_forum_layout; - } - - static [Trait.fromDiscord](data: any): Channel { - return new Channel(data); - } -} -import { GatewayObject } from "./base"; -import { Trait } from "./common"; -import { User, type DiscordUser } from "./user"; - -export enum ChannelType { - GUILD_TEXT = 0, - DM = 1, - GUILD_VOICE = 2, - GROUP_DM = 3, - GUILD_CATEGORY = 4, - GUILD_ANNOUNCEMENT = 5, - ANNOUNCEMENT_THREAD = 10, - PUBLIC_THREAD = 11, - PRIVATE_THREAD = 12, - GUILD_STAGE_VOICE = 13, - GUILD_DIRECTORY = 14, - GUILD_FORUM = 15, - GUILD_MEDIA = 16 -} - -export enum VideoQualityMode { - AUTO = 1, - FULL = 2 -} - -export enum ForumLayoutType { - NOT_SET = 0, - LIST_VIEW = 1, - GALLERY_VIEW = 2 -} - -export enum SortOrderType { - LATEST_ACTIVITY = 0, - CREATION_DATE = 1 -} - export class Channel extends GatewayObject { id: string; type: ChannelType; From 835271a4c775de0a59d06ccaec09b9660f7217aa Mon Sep 17 00:00:00 2001 From: "Jaron (aider)" Date: Sat, 15 Feb 2025 11:33:51 -0600 Subject: [PATCH 06/20] feat: Add DefaultReaction type to message types --- src/types/message.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/types/message.ts b/src/types/message.ts index 878bb97..e977f45 100644 --- a/src/types/message.ts +++ b/src/types/message.ts @@ -34,6 +34,11 @@ export type Component = Partial