diff --git a/src/helpers/channels/swap_channels.ts b/src/helpers/channels/swap_channels.ts index a1df26369..aeaa58503 100644 --- a/src/helpers/channels/swap_channels.ts +++ b/src/helpers/channels/swap_channels.ts @@ -3,8 +3,8 @@ import type { Bot } from "../../bot.ts"; /** Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permission. */ export async function swapChannels(bot: Bot, guildId: bigint, channelPositions: ModifyGuildChannelPositions[]) { - if (channelPositions.length < 2) { - throw "You must provide at least two channels to be swapped."; + if (!channelPositions.length) { + throw "You must provide at least one channels to be moved."; } return await bot.rest.runMethod( diff --git a/src/helpers/channels/threads/get_active_threads.ts b/src/helpers/channels/threads/get_active_threads.ts index 7fb73520c..a484a6b1e 100644 --- a/src/helpers/channels/threads/get_active_threads.ts +++ b/src/helpers/channels/threads/get_active_threads.ts @@ -3,10 +3,8 @@ import type { ListActiveThreads } from "../../../types/channels/threads/list_act import { Collection } from "../../../util/collection.ts"; // import { channelToThread } from "../../../util/transformers/channel_to_thread.ts"; -/** Returns all active threads in the channel, including public and private threads. Threads are ordered by their id, in descending order. Requires the VIEW_CHANNEL permission. */ -export async function getActiveThreads(bot: Bot, channelId: bigint) { - // await bot.utils.requireBotChannelPermissions(bot, channelId, ["VIEW_CHANNEL"]); - // // TODO: pagination +/** Returns all active threads in the guild, including public and private threads. Threads are ordered by their `id`, in descending order. */ +export async function getActiveThreads(bot: Bot, guildId: bigint) { // const result = (await bot.rest.runMethod( // bot.rest, // "get", diff --git a/src/helpers/channels/threads/start_thread.ts b/src/helpers/channels/threads/startThreadWithMessage.ts similarity index 79% rename from src/helpers/channels/threads/start_thread.ts rename to src/helpers/channels/threads/startThreadWithMessage.ts index 2c072ebdd..73bc0a1c7 100644 --- a/src/helpers/channels/threads/start_thread.ts +++ b/src/helpers/channels/threads/startThreadWithMessage.ts @@ -1,9 +1,9 @@ import type { Channel } from "../../../types/channels/channel.ts"; -import type { StartThread } from "../../../types/channels/threads/start_thread.ts"; +import type { StartThreadWithMessage } from "../../../types/channels/threads/start_thread.ts"; import type { Bot } from "../../../bot.ts"; /** Creates a new public thread from an existing message. Returns a thread channel. */ -export async function startThread(bot: Bot, channelId: bigint, messageId: bigint, options: StartThread) { +export async function startThreadWithMessage(bot: Bot, channelId: bigint, messageId: bigint, options: StartThreadWithMessage) { // const channel = await bot.cache.channels.get(channelId); // if (channel) { // if (!channel.isGuildTextBasedChannel) { diff --git a/src/helpers/channels/threads/start_private_thread.ts b/src/helpers/channels/threads/startThreadWithoutMessage.ts similarity index 71% rename from src/helpers/channels/threads/start_private_thread.ts rename to src/helpers/channels/threads/startThreadWithoutMessage.ts index b904e04dd..1fbc4ad86 100644 --- a/src/helpers/channels/threads/start_private_thread.ts +++ b/src/helpers/channels/threads/startThreadWithoutMessage.ts @@ -1,15 +1,16 @@ import type { Channel } from "../../../types/channels/channel.ts"; -import type { StartThread } from "../../../types/channels/threads/start_thread.ts"; +import type { StartThreadWithoutMessage } from "../../../types/channels/threads/start_thread.ts"; import type { Bot } from "../../../bot.ts"; /** Creates a new private thread. Returns a thread channel. */ -export async function startPrivateThread(bot: Bot, channelId: bigint, options: StartThread) { +export async function startThreadWithoutMessage(bot: Bot, channelId: bigint, options: StartThreadWithoutMessage) { // const channel = await bot.cache.channels.get(channelId); // if (channel) { // if (!channel.isGuildTextBasedChannel) throw new Error(bot.constants.Errors.INVALID_THREAD_PARENT_CHANNEL_TYPE); // if (channel.isNewsChannel) throw new Error(bot.constants.Errors.GUILD_NEWS_CHANNEL_ONLY_SUPPORT_PUBLIC_THREADS); // await bot.utils.requireBotChannelPermissions(bot, channel, ["SEND_MESSAGES", "USE_PRIVATE_THREADS"]); // } + // if (options.invitable && options.type !== PRIVATETHREAD) throw new Error("Invitiable option requires private threads."); // return channelToThread( // await bot.rest.runMethod(bot.rest, "post", bot.constants.endpoints.THREAD_START_PRIVATE(channelId), { // name: options.name, diff --git a/src/types/audit_log/audit_log.ts b/src/types/audit_log/audit_log.ts index 578a54d73..81e0336c2 100644 --- a/src/types/audit_log/audit_log.ts +++ b/src/types/audit_log/audit_log.ts @@ -13,4 +13,6 @@ export interface AuditLog { auditLogEntries: AuditLogEntry[]; /** List of partial integration objects */ integrations: Partial[]; + /** List of threads found in the audit log. */ + threads: Channel[]; } diff --git a/src/types/audit_log/audit_log_change.ts b/src/types/audit_log/audit_log_change.ts index 80f5f2d1d..176a986a3 100644 --- a/src/types/audit_log/audit_log_change.ts +++ b/src/types/audit_log/audit_log_change.ts @@ -54,7 +54,9 @@ export type AuditLogChange = | "expire_behavior" | "expire_grace_period" | "user_limit" - | "privacy_level"; + | "privacy_level" + | "auto_archive_duration" + | "default_auto_archive_duration"; } | { newValue: Partial; @@ -64,7 +66,7 @@ export type AuditLogChange = | { newValue: boolean; oldValue: boolean; - key: "widget_enabled" | "nsfw" | "hoist" | "mentionable" | "temporary" | "deaf" | "mute" | "enable_emoticons"; + key: "widget_enabled" | "nsfw" | "hoist" | "mentionable" | "temporary" | "deaf" | "mute" | "enable_emoticons" | "archived" | "locked"; } | { newValue: Overwrite[]; diff --git a/src/types/audit_log/audit_log_events.ts b/src/types/audit_log/audit_log_events.ts index de1663da1..7c28ec77d 100644 --- a/src/types/audit_log/audit_log_events.ts +++ b/src/types/audit_log/audit_log_events.ts @@ -38,6 +38,12 @@ export enum DiscordAuditLogEvents { StageInstanceCreate, StageInstanceUpdate, StageInstanceDelete, + StickerCreate = 90, + StickerUpdate, + StickerDelete, + ThreadCreate = 110, + ThreadUpdate, + ThreadDelete, } export type AuditLogEvents = DiscordAuditLogEvents; diff --git a/src/types/channels/threads/list_active_threads.ts b/src/types/channels/threads/list_active_threads.ts index 55753d444..529e0f54c 100644 --- a/src/types/channels/threads/list_active_threads.ts +++ b/src/types/channels/threads/list_active_threads.ts @@ -7,6 +7,4 @@ export interface ListActiveThreads { threads: Channel[]; /** A thread member object for each returned thread the current user has joined */ members: ThreadMember[]; - /** Whether there are potentially additional threads that could be returned on subsequent call */ - hasMore: boolean; } diff --git a/src/types/channels/threads/modify_thread.ts b/src/types/channels/threads/modify_thread.ts index 2c3023a85..ca1bee40c 100644 --- a/src/types/channels/threads/modify_thread.ts +++ b/src/types/channels/threads/modify_thread.ts @@ -8,6 +8,8 @@ export interface ModifyThread { autoArchiveDuration?: 60 | 1440 | 4320 | 10080; /** When a thread is locked, only users with `MANAGE_THREADS` can unarchive it */ locked?: boolean; + /** whether non-moderators can add other non-moderators to a thread; only available on private threads */ + invitable?: boolean; /** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission `MANAGE_MESSAGES`, `MANAGE_THREAD` or `MANAGE_CHANNEL` are unaffected */ rateLimitPerUser?: number; } diff --git a/src/types/channels/threads/start_thread.ts b/src/types/channels/threads/start_thread.ts index 66458af97..e68e66280 100644 --- a/src/types/channels/threads/start_thread.ts +++ b/src/types/channels/threads/start_thread.ts @@ -1,7 +1,23 @@ +import { DiscordChannelTypes } from "../channel_types.ts"; + // TODO: add docs link -export interface StartThread { +export interface StartThreadBase { /** 1-100 character thread name */ name: string; /** Duration in minutes to automatically archive the thread after recent activity */ autoArchiveDuration: 60 | 1440 | 4320 | 10080; + /** The reason you are creating the thread */ + reason?: string; } + +export interface StartThreadWithMessage extends StartThreadBase { + /** The message id with which to start a thread on. */ + messageId: bigint; +} + +export interface StartThreadWithoutMessage extends StartThreadBase { + /** the type of thread to create */ + type: DiscordChannelTypes.GuildNewsThread | DiscordChannelTypes.GuildPublicThread | DiscordChannelTypes.GuildPrivateThread; + /** whether non-moderators can add other non-moderators to a thread; only available when creating a private thread */ + invitable?: boolean; +} \ No newline at end of file diff --git a/src/types/channels/threads/thread_members_update.ts b/src/types/channels/threads/thread_members_update.ts index a31326c6a..1a01fd2cc 100644 --- a/src/types/channels/threads/thread_members_update.ts +++ b/src/types/channels/threads/thread_members_update.ts @@ -26,4 +26,7 @@ export interface ThreadMembersUpdateModified extends ThreadMembersUpdateBase { addedMembers?: ThreadMemberModified[]; /** The id of the users who were removed from the thread */ removedMemberIds?: bigint[]; + // TODO: verify this + // \* In this gateway event, the thread member objects will also include the [guild member](#DOCS_RESOURCES_GUILD/guild-member-object) and [presence](#DOCS_TOPICS_GATEWAY/presence) objects for each added thread member. } + diff --git a/src/types/channels/threads/thread_metadata.ts b/src/types/channels/threads/thread_metadata.ts index 60d92bbcd..d0d56afe8 100644 --- a/src/types/channels/threads/thread_metadata.ts +++ b/src/types/channels/threads/thread_metadata.ts @@ -8,4 +8,6 @@ export interface ThreadMetadata { archiveTimestamp: string; /** When a thread is locked, only users with `MANAGE_THREADS` can unarchive it */ locked?: boolean; + /** whether non-moderators can add other non-moderators to a thread; only available on private threads */ + invitable?: boolean; } diff --git a/src/types/codes/json_error_codes.ts b/src/types/codes/json_error_codes.ts index 235bb8428..d16729a04 100644 --- a/src/types/codes/json_error_codes.ts +++ b/src/types/codes/json_error_codes.ts @@ -28,15 +28,19 @@ export enum DiscordJsonErrorCodes { UnknownStoreDirectoryLayout, UnknownRedistributable = 10036, UnknownGiftCode = 10038, + UnknownStream = 10049, + UnknownPremiumServerSubscribeCooldown, UnknownGuildTemplate = 10057, UnknownDiscoveryCategory = 10059, UnknownSticker, UnknownInteraction = 10062, UnknownApplicationCommand = 10063, UnknownApplicationCommandPermissions = 10066, - UnknownStageInstance, + UnknownStageInstance, UnknownGuildMemberVerificationForm, UnknownGuildWelcomeScreen, + UnknownGuildScheduledEvent, + UnknownGuildScheduledEventUser, BotsCannotUseThisEndpoint = 20001, OnlyBotsCanUseThisEndpoint, ExplicitContentCannotBeSentToTheDesiredRecipient = 20009, @@ -65,6 +69,7 @@ export enum DiscordJsonErrorCodes { MaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035, MaximumNumberOfBansFetchesHasBeenReached = 30037, MaximumNumberOfStickersReached = 30039, + MaximumNumberOfPruneRequestsHasBeenReachedTryAgainLater, UnauthorizedProvideAValidTokenAndTryAgain = 40001, YouNeedToVerifyYourAccountInOrderToPerformThisAction, YouAreOpeningDirectMessagesTooFast, @@ -110,11 +115,14 @@ export enum DiscordJsonErrorCodes { TriedToPerformAnOperationOnAnArchivedThreadSuchAsEditingAMessageOrAddingAUserToTheThread = 50083, InvalidThreadNotificationSettings, BeforeValueIsEarlierThanTheThreadCreationDate, + ThisServerIsNotAvailableInYourLocation = 50095, + ThisServerNeedsMonetizationEnabledInOrderToPerformThisAction = 50097, TwoFactorIsRequiredForThisOperation = 60003, NoUsersWithDiscordTagExist = 80004, ReqctionWasBlocked = 90001, ApiResourceIsCurrentlyOverloadedTryAgainALittleLater = 130000, TheStageIsAlreadyOpen = 150006, + CannotReplyWithoutPermissionToReadMessageHistory = 160002, AThreadHasAlreadyBeenCreatedForThisMessage = 160004, ThreadIsLocked = 160005, MaximumNumberOfActiveThreadsReached = 160006, diff --git a/src/types/embeds/embed_author.ts b/src/types/embeds/embed_author.ts index 4ec07a7e9..5920ca38c 100644 --- a/src/types/embeds/embed_author.ts +++ b/src/types/embeds/embed_author.ts @@ -1,7 +1,7 @@ /** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */ export interface EmbedAuthor { /** Name of author */ - name?: string; + name: string; /** Url of author */ url?: string; /** Url of author icon (only supports http(s) and attachments) */ diff --git a/src/types/embeds/embed_image.ts b/src/types/embeds/embed_image.ts index 0b010c56a..d5c9c76c2 100644 --- a/src/types/embeds/embed_image.ts +++ b/src/types/embeds/embed_image.ts @@ -1,7 +1,7 @@ /** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */ export interface EmbedImage { /** Source url of image (only supports http(s) and attachments) */ - url?: string; + url: string; /** A proxied url of the image */ proxyUrl?: string; /** Height of image */ diff --git a/src/types/embeds/embed_thumbnail.ts b/src/types/embeds/embed_thumbnail.ts index 824c6f085..cadb660dc 100644 --- a/src/types/embeds/embed_thumbnail.ts +++ b/src/types/embeds/embed_thumbnail.ts @@ -1,7 +1,7 @@ /** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */ export interface EmbedThumbnail { /** Source url of thumbnail (only supports http(s) and attachments) */ - url?: string; + url: string; /** A proxied url of the thumbnail */ proxyUrl?: string; /** Height of thumbnail */ diff --git a/src/types/messages/message_types.ts b/src/types/messages/message_types.ts index 540359326..32b331e76 100644 --- a/src/types/messages/message_types.ts +++ b/src/types/messages/message_types.ts @@ -18,9 +18,11 @@ export enum DiscordMessageTypes { GuildDiscoveryGracePeriodInitialWarning, GuildDiscoveryGracePeriodFinalWarning, ThreadCreated, - Reply = 19, - ApplicationCommand, - GuildInviteReminder = 22, + Reply, + ChatInputCommand, + ThreadStarterMessage, + GuildInviteReminder, + ContextMenuCommand, } export type MessageTypes = DiscordMessageTypes; diff --git a/src/types/users/user.ts b/src/types/users/user.ts index 04915cfa0..93177d54c 100644 --- a/src/types/users/user.ts +++ b/src/types/users/user.ts @@ -29,4 +29,8 @@ export interface User { premiumType?: DiscordPremiumTypes; /** The public flags on a user's account */ publicFlags?: DiscordUserFlags; + /** the user's banner, or null if unset */ + banner?: string; + /** the user's banner color encoded as an integer representation of hexadecimal color code */ + accent_color?: number; } diff --git a/src/util/constants.ts b/src/util/constants.ts index 8305e79de..ac62361cf 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -60,7 +60,7 @@ export const endpoints = { THREAD_START_PUBLIC: (channelId: bigint, messageId: bigint) => `${endpoints.CHANNEL_MESSAGE(channelId, messageId)}/threads`, THREAD_START_PRIVATE: (channelId: bigint) => `${CHANNEL_BASE(channelId)}/threads`, - THREAD_ACTIVE: (channelId: bigint) => `${CHANNEL_BASE(channelId)}/threads/active`, + THREAD_ACTIVE: (guildId: bigint) => `${GUILDS_BASE(guildId)}/threads/active`, THREAD_MEMBERS: (channelId: bigint) => `${CHANNEL_BASE(channelId)}/thread-members`, THREAD_ME: (channelId: bigint) => `${endpoints.THREAD_MEMBERS(channelId)}/@me`, THREAD_USER: (channelId: bigint, userId: bigint) => `${endpoints.THREAD_MEMBERS(channelId)}/${userId}`,