mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
more stuff
This commit is contained in:
@@ -3,8 +3,8 @@ import type { Bot } from "../../bot.ts";
|
|||||||
|
|
||||||
/** Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permission. */
|
/** Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permission. */
|
||||||
export async function swapChannels(bot: Bot, guildId: bigint, channelPositions: ModifyGuildChannelPositions[]) {
|
export async function swapChannels(bot: Bot, guildId: bigint, channelPositions: ModifyGuildChannelPositions[]) {
|
||||||
if (channelPositions.length < 2) {
|
if (!channelPositions.length) {
|
||||||
throw "You must provide at least two channels to be swapped.";
|
throw "You must provide at least one channels to be moved.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return await bot.rest.runMethod<undefined>(
|
return await bot.rest.runMethod<undefined>(
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ import type { ListActiveThreads } from "../../../types/channels/threads/list_act
|
|||||||
import { Collection } from "../../../util/collection.ts";
|
import { Collection } from "../../../util/collection.ts";
|
||||||
// import { channelToThread } from "../../../util/transformers/channel_to_thread.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. */
|
/** 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, channelId: bigint) {
|
export async function getActiveThreads(bot: Bot, guildId: bigint) {
|
||||||
// await bot.utils.requireBotChannelPermissions(bot, channelId, ["VIEW_CHANNEL"]);
|
|
||||||
// // TODO: pagination
|
|
||||||
// const result = (await bot.rest.runMethod(
|
// const result = (await bot.rest.runMethod(
|
||||||
// bot.rest,
|
// bot.rest,
|
||||||
// "get",
|
// "get",
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
import type { Channel } from "../../../types/channels/channel.ts";
|
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";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/** Creates a new public thread from an existing message. Returns a thread channel. */
|
/** 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);
|
// const channel = await bot.cache.channels.get(channelId);
|
||||||
// if (channel) {
|
// if (channel) {
|
||||||
// if (!channel.isGuildTextBasedChannel) {
|
// if (!channel.isGuildTextBasedChannel) {
|
||||||
+3
-2
@@ -1,15 +1,16 @@
|
|||||||
import type { Channel } from "../../../types/channels/channel.ts";
|
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";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/** Creates a new private thread. Returns a thread channel. */
|
/** 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);
|
// const channel = await bot.cache.channels.get(channelId);
|
||||||
// if (channel) {
|
// if (channel) {
|
||||||
// if (!channel.isGuildTextBasedChannel) throw new Error(bot.constants.Errors.INVALID_THREAD_PARENT_CHANNEL_TYPE);
|
// 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);
|
// 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"]);
|
// 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(
|
// return channelToThread(
|
||||||
// await bot.rest.runMethod<Channel>(bot.rest, "post", bot.constants.endpoints.THREAD_START_PRIVATE(channelId), {
|
// await bot.rest.runMethod<Channel>(bot.rest, "post", bot.constants.endpoints.THREAD_START_PRIVATE(channelId), {
|
||||||
// name: options.name,
|
// name: options.name,
|
||||||
@@ -13,4 +13,6 @@ export interface AuditLog {
|
|||||||
auditLogEntries: AuditLogEntry[];
|
auditLogEntries: AuditLogEntry[];
|
||||||
/** List of partial integration objects */
|
/** List of partial integration objects */
|
||||||
integrations: Partial<Integration>[];
|
integrations: Partial<Integration>[];
|
||||||
|
/** List of threads found in the audit log. */
|
||||||
|
threads: Channel[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ export type AuditLogChange =
|
|||||||
| "expire_behavior"
|
| "expire_behavior"
|
||||||
| "expire_grace_period"
|
| "expire_grace_period"
|
||||||
| "user_limit"
|
| "user_limit"
|
||||||
| "privacy_level";
|
| "privacy_level"
|
||||||
|
| "auto_archive_duration"
|
||||||
|
| "default_auto_archive_duration";
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
newValue: Partial<Role>;
|
newValue: Partial<Role>;
|
||||||
@@ -64,7 +66,7 @@ export type AuditLogChange =
|
|||||||
| {
|
| {
|
||||||
newValue: boolean;
|
newValue: boolean;
|
||||||
oldValue: 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[];
|
newValue: Overwrite[];
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ export enum DiscordAuditLogEvents {
|
|||||||
StageInstanceCreate,
|
StageInstanceCreate,
|
||||||
StageInstanceUpdate,
|
StageInstanceUpdate,
|
||||||
StageInstanceDelete,
|
StageInstanceDelete,
|
||||||
|
StickerCreate = 90,
|
||||||
|
StickerUpdate,
|
||||||
|
StickerDelete,
|
||||||
|
ThreadCreate = 110,
|
||||||
|
ThreadUpdate,
|
||||||
|
ThreadDelete,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AuditLogEvents = DiscordAuditLogEvents;
|
export type AuditLogEvents = DiscordAuditLogEvents;
|
||||||
|
|||||||
@@ -7,6 +7,4 @@ export interface ListActiveThreads {
|
|||||||
threads: Channel[];
|
threads: Channel[];
|
||||||
/** A thread member object for each returned thread the current user has joined */
|
/** A thread member object for each returned thread the current user has joined */
|
||||||
members: ThreadMember[];
|
members: ThreadMember[];
|
||||||
/** Whether there are potentially additional threads that could be returned on subsequent call */
|
|
||||||
hasMore: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ export interface ModifyThread {
|
|||||||
autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
|
autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
|
||||||
/** When a thread is locked, only users with `MANAGE_THREADS` can unarchive it */
|
/** When a thread is locked, only users with `MANAGE_THREADS` can unarchive it */
|
||||||
locked?: boolean;
|
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 */
|
/** 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;
|
rateLimitPerUser?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,23 @@
|
|||||||
|
import { DiscordChannelTypes } from "../channel_types.ts";
|
||||||
|
|
||||||
// TODO: add docs link
|
// TODO: add docs link
|
||||||
export interface StartThread {
|
export interface StartThreadBase {
|
||||||
/** 1-100 character thread name */
|
/** 1-100 character thread name */
|
||||||
name: string;
|
name: string;
|
||||||
/** Duration in minutes to automatically archive the thread after recent activity */
|
/** Duration in minutes to automatically archive the thread after recent activity */
|
||||||
autoArchiveDuration: 60 | 1440 | 4320 | 10080;
|
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;
|
||||||
}
|
}
|
||||||
@@ -26,4 +26,7 @@ export interface ThreadMembersUpdateModified extends ThreadMembersUpdateBase {
|
|||||||
addedMembers?: ThreadMemberModified[];
|
addedMembers?: ThreadMemberModified[];
|
||||||
/** The id of the users who were removed from the thread */
|
/** The id of the users who were removed from the thread */
|
||||||
removedMemberIds?: bigint[];
|
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ export interface ThreadMetadata {
|
|||||||
archiveTimestamp: string;
|
archiveTimestamp: string;
|
||||||
/** When a thread is locked, only users with `MANAGE_THREADS` can unarchive it */
|
/** When a thread is locked, only users with `MANAGE_THREADS` can unarchive it */
|
||||||
locked?: boolean;
|
locked?: boolean;
|
||||||
|
/** whether non-moderators can add other non-moderators to a thread; only available on private threads */
|
||||||
|
invitable?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ export enum DiscordJsonErrorCodes {
|
|||||||
UnknownStoreDirectoryLayout,
|
UnknownStoreDirectoryLayout,
|
||||||
UnknownRedistributable = 10036,
|
UnknownRedistributable = 10036,
|
||||||
UnknownGiftCode = 10038,
|
UnknownGiftCode = 10038,
|
||||||
|
UnknownStream = 10049,
|
||||||
|
UnknownPremiumServerSubscribeCooldown,
|
||||||
UnknownGuildTemplate = 10057,
|
UnknownGuildTemplate = 10057,
|
||||||
UnknownDiscoveryCategory = 10059,
|
UnknownDiscoveryCategory = 10059,
|
||||||
UnknownSticker,
|
UnknownSticker,
|
||||||
@@ -37,6 +39,8 @@ export enum DiscordJsonErrorCodes {
|
|||||||
UnknownStageInstance,
|
UnknownStageInstance,
|
||||||
UnknownGuildMemberVerificationForm,
|
UnknownGuildMemberVerificationForm,
|
||||||
UnknownGuildWelcomeScreen,
|
UnknownGuildWelcomeScreen,
|
||||||
|
UnknownGuildScheduledEvent,
|
||||||
|
UnknownGuildScheduledEventUser,
|
||||||
BotsCannotUseThisEndpoint = 20001,
|
BotsCannotUseThisEndpoint = 20001,
|
||||||
OnlyBotsCanUseThisEndpoint,
|
OnlyBotsCanUseThisEndpoint,
|
||||||
ExplicitContentCannotBeSentToTheDesiredRecipient = 20009,
|
ExplicitContentCannotBeSentToTheDesiredRecipient = 20009,
|
||||||
@@ -65,6 +69,7 @@ export enum DiscordJsonErrorCodes {
|
|||||||
MaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035,
|
MaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035,
|
||||||
MaximumNumberOfBansFetchesHasBeenReached = 30037,
|
MaximumNumberOfBansFetchesHasBeenReached = 30037,
|
||||||
MaximumNumberOfStickersReached = 30039,
|
MaximumNumberOfStickersReached = 30039,
|
||||||
|
MaximumNumberOfPruneRequestsHasBeenReachedTryAgainLater,
|
||||||
UnauthorizedProvideAValidTokenAndTryAgain = 40001,
|
UnauthorizedProvideAValidTokenAndTryAgain = 40001,
|
||||||
YouNeedToVerifyYourAccountInOrderToPerformThisAction,
|
YouNeedToVerifyYourAccountInOrderToPerformThisAction,
|
||||||
YouAreOpeningDirectMessagesTooFast,
|
YouAreOpeningDirectMessagesTooFast,
|
||||||
@@ -110,11 +115,14 @@ export enum DiscordJsonErrorCodes {
|
|||||||
TriedToPerformAnOperationOnAnArchivedThreadSuchAsEditingAMessageOrAddingAUserToTheThread = 50083,
|
TriedToPerformAnOperationOnAnArchivedThreadSuchAsEditingAMessageOrAddingAUserToTheThread = 50083,
|
||||||
InvalidThreadNotificationSettings,
|
InvalidThreadNotificationSettings,
|
||||||
BeforeValueIsEarlierThanTheThreadCreationDate,
|
BeforeValueIsEarlierThanTheThreadCreationDate,
|
||||||
|
ThisServerIsNotAvailableInYourLocation = 50095,
|
||||||
|
ThisServerNeedsMonetizationEnabledInOrderToPerformThisAction = 50097,
|
||||||
TwoFactorIsRequiredForThisOperation = 60003,
|
TwoFactorIsRequiredForThisOperation = 60003,
|
||||||
NoUsersWithDiscordTagExist = 80004,
|
NoUsersWithDiscordTagExist = 80004,
|
||||||
ReqctionWasBlocked = 90001,
|
ReqctionWasBlocked = 90001,
|
||||||
ApiResourceIsCurrentlyOverloadedTryAgainALittleLater = 130000,
|
ApiResourceIsCurrentlyOverloadedTryAgainALittleLater = 130000,
|
||||||
TheStageIsAlreadyOpen = 150006,
|
TheStageIsAlreadyOpen = 150006,
|
||||||
|
CannotReplyWithoutPermissionToReadMessageHistory = 160002,
|
||||||
AThreadHasAlreadyBeenCreatedForThisMessage = 160004,
|
AThreadHasAlreadyBeenCreatedForThisMessage = 160004,
|
||||||
ThreadIsLocked = 160005,
|
ThreadIsLocked = 160005,
|
||||||
MaximumNumberOfActiveThreadsReached = 160006,
|
MaximumNumberOfActiveThreadsReached = 160006,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */
|
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */
|
||||||
export interface EmbedAuthor {
|
export interface EmbedAuthor {
|
||||||
/** Name of author */
|
/** Name of author */
|
||||||
name?: string;
|
name: string;
|
||||||
/** Url of author */
|
/** Url of author */
|
||||||
url?: string;
|
url?: string;
|
||||||
/** Url of author icon (only supports http(s) and attachments) */
|
/** Url of author icon (only supports http(s) and attachments) */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */
|
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */
|
||||||
export interface EmbedImage {
|
export interface EmbedImage {
|
||||||
/** Source url of image (only supports http(s) and attachments) */
|
/** Source url of image (only supports http(s) and attachments) */
|
||||||
url?: string;
|
url: string;
|
||||||
/** A proxied url of the image */
|
/** A proxied url of the image */
|
||||||
proxyUrl?: string;
|
proxyUrl?: string;
|
||||||
/** Height of image */
|
/** Height of image */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */
|
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */
|
||||||
export interface EmbedThumbnail {
|
export interface EmbedThumbnail {
|
||||||
/** Source url of thumbnail (only supports http(s) and attachments) */
|
/** Source url of thumbnail (only supports http(s) and attachments) */
|
||||||
url?: string;
|
url: string;
|
||||||
/** A proxied url of the thumbnail */
|
/** A proxied url of the thumbnail */
|
||||||
proxyUrl?: string;
|
proxyUrl?: string;
|
||||||
/** Height of thumbnail */
|
/** Height of thumbnail */
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ export enum DiscordMessageTypes {
|
|||||||
GuildDiscoveryGracePeriodInitialWarning,
|
GuildDiscoveryGracePeriodInitialWarning,
|
||||||
GuildDiscoveryGracePeriodFinalWarning,
|
GuildDiscoveryGracePeriodFinalWarning,
|
||||||
ThreadCreated,
|
ThreadCreated,
|
||||||
Reply = 19,
|
Reply,
|
||||||
ApplicationCommand,
|
ChatInputCommand,
|
||||||
GuildInviteReminder = 22,
|
ThreadStarterMessage,
|
||||||
|
GuildInviteReminder,
|
||||||
|
ContextMenuCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MessageTypes = DiscordMessageTypes;
|
export type MessageTypes = DiscordMessageTypes;
|
||||||
|
|||||||
@@ -29,4 +29,8 @@ export interface User {
|
|||||||
premiumType?: DiscordPremiumTypes;
|
premiumType?: DiscordPremiumTypes;
|
||||||
/** The public flags on a user's account */
|
/** The public flags on a user's account */
|
||||||
publicFlags?: DiscordUserFlags;
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export const endpoints = {
|
|||||||
THREAD_START_PUBLIC: (channelId: bigint, messageId: bigint) =>
|
THREAD_START_PUBLIC: (channelId: bigint, messageId: bigint) =>
|
||||||
`${endpoints.CHANNEL_MESSAGE(channelId, messageId)}/threads`,
|
`${endpoints.CHANNEL_MESSAGE(channelId, messageId)}/threads`,
|
||||||
THREAD_START_PRIVATE: (channelId: bigint) => `${CHANNEL_BASE(channelId)}/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_MEMBERS: (channelId: bigint) => `${CHANNEL_BASE(channelId)}/thread-members`,
|
||||||
THREAD_ME: (channelId: bigint) => `${endpoints.THREAD_MEMBERS(channelId)}/@me`,
|
THREAD_ME: (channelId: bigint) => `${endpoints.THREAD_MEMBERS(channelId)}/@me`,
|
||||||
THREAD_USER: (channelId: bigint, userId: bigint) => `${endpoints.THREAD_MEMBERS(channelId)}/${userId}`,
|
THREAD_USER: (channelId: bigint, userId: bigint) => `${endpoints.THREAD_MEMBERS(channelId)}/${userId}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user