mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
add(types): stage discovery privacy fields (#957)
* feat: add stage discovery fields * feat: add stage discovery fields * Update src/types/channels/privacy_level.ts Co-authored-by: ITOH <to@itoh.at> * change: prettier code Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Co-authored-by: ITOH <to@itoh.at> Co-authored-by: Skillz4Killz <Skillz4Killz@users.noreply.github.com>
This commit is contained in:
@@ -6,9 +6,11 @@ import type { StageInstance } from "../../types/channels/stage_instance.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { ChannelTypes } from "../../types/channels/channel_types.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
import { PrivacyLevel } from "../../types/channels/privacy_level.ts";
|
||||
import { snakelize } from "../../util/utils.ts";
|
||||
|
||||
/** Creates a new Stage instance associated to a Stage channel. Requires the user to be a moderator of the Stage channel. */
|
||||
export async function createStageInstance(channelId: bigint, topic: string) {
|
||||
export async function createStageInstance(channelId: bigint, topic: string, privacyLevel?: PrivacyLevel) {
|
||||
const channel = await cacheHandlers.get("channels", channelId);
|
||||
|
||||
if (channel) {
|
||||
@@ -23,8 +25,13 @@ export async function createStageInstance(channelId: bigint, topic: string) {
|
||||
throw new Error(Errors.INVALID_TOPIC_LENGTH);
|
||||
}
|
||||
|
||||
return await rest.runMethod<StageInstance>("post", endpoints.STAGE_INSTANCES, {
|
||||
channel_id: channelId,
|
||||
topic,
|
||||
});
|
||||
return await rest.runMethod<StageInstance>(
|
||||
"post",
|
||||
endpoints.STAGE_INSTANCES,
|
||||
snakelize({
|
||||
channelId,
|
||||
topic,
|
||||
privacyLevel,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,13 @@ import { validateLength } from "../../util/validate_length.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
import { ChannelTypes } from "../../types/channels/channel_types.ts";
|
||||
import { snakelize } from "../../util/utils.ts";
|
||||
|
||||
/** Updates fields of an existing Stage instance. Requires the user to be a moderator of the Stage channel. */
|
||||
export async function updateStageInstance(channelId: bigint, topic: string) {
|
||||
export async function updateStageInstance(
|
||||
channelId: bigint,
|
||||
data: Partial<Pick<StageInstance, "topic" | "privacyLevel">> = {}
|
||||
) {
|
||||
const channel = await cacheHandlers.get("channels", channelId);
|
||||
|
||||
if (channel) {
|
||||
@@ -20,7 +24,8 @@ export async function updateStageInstance(channelId: bigint, topic: string) {
|
||||
}
|
||||
|
||||
if (
|
||||
!validateLength(topic, {
|
||||
data?.topic &&
|
||||
!validateLength(data.topic, {
|
||||
min: 1,
|
||||
max: 120,
|
||||
})
|
||||
@@ -28,7 +33,5 @@ export async function updateStageInstance(channelId: bigint, topic: string) {
|
||||
throw new Error(Errors.INVALID_TOPIC_LENGTH);
|
||||
}
|
||||
|
||||
return await rest.runMethod<StageInstance>("patch", endpoints.STAGE_INSTANCE(channelId), {
|
||||
topic,
|
||||
});
|
||||
return await rest.runMethod<StageInstance>("patch", endpoints.STAGE_INSTANCE(channelId), snakelize(data));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user