more stuff

This commit is contained in:
Skillz4Killz
2021-11-09 02:27:28 +00:00
committed by GitHub
parent 48c29eeba7
commit 4d845db515
19 changed files with 67 additions and 23 deletions
+2 -2
View File
@@ -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<undefined>(
@@ -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",
@@ -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) {
@@ -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<Channel>(bot.rest, "post", bot.constants.endpoints.THREAD_START_PRIVATE(channelId), {
// name: options.name,
+2
View File
@@ -13,4 +13,6 @@ export interface AuditLog {
auditLogEntries: AuditLogEntry[];
/** List of partial integration objects */
integrations: Partial<Integration>[];
/** List of threads found in the audit log. */
threads: Channel[];
}
+4 -2
View File
@@ -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<Role>;
@@ -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[];
+6
View File
@@ -38,6 +38,12 @@ export enum DiscordAuditLogEvents {
StageInstanceCreate,
StageInstanceUpdate,
StageInstanceDelete,
StickerCreate = 90,
StickerUpdate,
StickerDelete,
ThreadCreate = 110,
ThreadUpdate,
ThreadDelete,
}
export type AuditLogEvents = DiscordAuditLogEvents;
@@ -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;
}
@@ -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;
}
+17 -1
View File
@@ -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;
}
@@ -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.
}
@@ -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;
}
+8
View File
@@ -28,6 +28,8 @@ export enum DiscordJsonErrorCodes {
UnknownStoreDirectoryLayout,
UnknownRedistributable = 10036,
UnknownGiftCode = 10038,
UnknownStream = 10049,
UnknownPremiumServerSubscribeCooldown,
UnknownGuildTemplate = 10057,
UnknownDiscoveryCategory = 10059,
UnknownSticker,
@@ -37,6 +39,8 @@ export enum DiscordJsonErrorCodes {
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,
+1 -1
View File
@@ -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) */
+1 -1
View File
@@ -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 */
+1 -1
View File
@@ -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 */
+5 -3
View File
@@ -18,9 +18,11 @@ export enum DiscordMessageTypes {
GuildDiscoveryGracePeriodInitialWarning,
GuildDiscoveryGracePeriodFinalWarning,
ThreadCreated,
Reply = 19,
ApplicationCommand,
GuildInviteReminder = 22,
Reply,
ChatInputCommand,
ThreadStarterMessage,
GuildInviteReminder,
ContextMenuCommand,
}
export type MessageTypes = DiscordMessageTypes;
+4
View File
@@ -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;
}
+1 -1
View File
@@ -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}`,