diff --git a/helpers/channels/createStageInstance.ts b/helpers/channels/createStageInstance.ts index 429bb2c8a..b18afdaeb 100644 --- a/helpers/channels/createStageInstance.ts +++ b/helpers/channels/createStageInstance.ts @@ -2,16 +2,24 @@ import type { Bot } from "../../bot.ts"; import { DiscordStageInstance } from "../../types/discord.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(bot: Bot, channelId: bigint, topic: string) { +export async function createStageInstance(bot: Bot, options: CreateStageInstance) { const result = await bot.rest.runMethod( bot.rest, "post", bot.constants.endpoints.STAGE_INSTANCES(), { - channel_id: channelId.toString(), - topic, + channel_id: options.channelId.toString(), + topic: options.topic, + send_start_notification: options.sendStartNotification, }, ); return bot.transformers.stageInstance(bot, result); } + +export interface CreateStageInstance { + channelId: bigint; + topic: string; + /** Notify @everyone that the stage instance has started. Requires the MENTION_EVERYONE permission. */ + sendStartNotification?: boolean; +} diff --git a/plugins/permissions/src/channels/stage.ts b/plugins/permissions/src/channels/stage.ts index a8f2db218..868d4770c 100644 --- a/plugins/permissions/src/channels/stage.ts +++ b/plugins/permissions/src/channels/stage.ts @@ -1,23 +1,29 @@ -import { BotWithCache } from "../../deps.ts"; +import { BotWithCache, PermissionStrings } from "../../deps.ts"; import { requireBotChannelPermissions } from "../permissions.ts"; export function createStageInstance(bot: BotWithCache) { const createStageInstanceOld = bot.helpers.createStageInstance; - bot.helpers.createStageInstance = async function (channelId, topic) { - if (!bot.utils.validateLength(topic, { max: 120, min: 1 })) { + bot.helpers.createStageInstance = async function (options) { + if (!bot.utils.validateLength(options.topic, { max: 120, min: 1 })) { throw new Error( "The topic length for creating a stage instance must be between 1-120.", ); } - requireBotChannelPermissions(bot, channelId, [ + const perms = new Set([ "MANAGE_CHANNELS", "MUTE_MEMBERS", "MOVE_MEMBERS", ]); + + if (options.sendStartNotification) { + perms.add("MENTION_EVERYONE"); + } - return await createStageInstanceOld(channelId, topic); + requireBotChannelPermissions(bot, options.channelId, [...perms.values()]); + + return await createStageInstanceOld(options); }; }