123 lines
4.2 KiB
TypeScript
123 lines
4.2 KiB
TypeScript
// Metro module 8337 (f8338).
|
|
import { createChannelRecordFromServer } from "../../records/ChannelRecord";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import { GuildScheduledEventEntityTypes, GuildScheduledEventPrivacyLevel } from "./GuildScheduledEventsConstants";
|
|
import { ChannelTypes } from "../../Constants";
|
|
import CreateChannelActionCreators from "../../actions/CreateChannelActionCreators";
|
|
import Module38 from "../../_bundle/Module38";
|
|
import { startStageInstance } from "../stage_channels/StageInstanceActionCreators";
|
|
import GuildScheduledEventsActionCreators from "./GuildScheduledEventsActionCreators";
|
|
let findOrCreateEventChannel;
|
|
const createStageChannelForEvent = async function createStageChannelForEvent(c26189_0, c26189_1, c26189_2) {
|
|
let r103;
|
|
let c26189_4;
|
|
let c29944_2, c29944_0, c29944_1, c29944_3, c29944_4;
|
|
L16: {
|
|
c26189_4 = void 0;
|
|
c29944_2 = void 0;
|
|
c29944_0 = c26189_0;
|
|
c29944_1 = c26189_1;
|
|
let r33 = c26189_2;
|
|
if (r33 === void 0) {
|
|
r33 = [];
|
|
}
|
|
c29944_2 = r33;
|
|
c29944_3 = void 0;
|
|
c29944_4 = void 0;
|
|
await void 0;
|
|
c29944_3 = [];
|
|
const r48 = c29944_3;
|
|
r48.push.apply(r48, [...c29944_2]);
|
|
c29944_4 = await CreateChannelActionCreators.createChannel({
|
|
guildId: c29944_0.id,
|
|
type: ChannelTypes.GUILD_STAGE_VOICE,
|
|
name: c29944_1.substring(0, 100),
|
|
permissionOverwrites: c29944_3
|
|
});
|
|
if (c29944_4 != null && c29944_4.status === 201) {
|
|
r103 = (0, createChannelRecordFromServer)(c29944_4.body);
|
|
break L16;
|
|
}
|
|
throw new Error("Can't create channel for event");
|
|
}
|
|
return r103;
|
|
};
|
|
findOrCreateEventChannel = function findOrCreateEventChannel(a0, a1) {
|
|
const { guild_id, channel_id } = a0;
|
|
const guild = GuildStore.getGuild(guild_id);
|
|
if (guild == null) {
|
|
return Promise.resolve(null);
|
|
}
|
|
const channel = ChannelStore.getChannel(channel_id);
|
|
return channel == null ? createStageChannelForEvent(guild, a0.name, a1) : Promise.resolve(channel);
|
|
};
|
|
export { createStageChannelForEvent };
|
|
export { findOrCreateEventChannel };
|
|
export async function preStartEventActions(c26190_0, c26190_1) {
|
|
let c26190_3;
|
|
let c29945_0;
|
|
L13: {
|
|
c26190_3 = void 0;
|
|
c29945_0 = void 0;
|
|
if (c26190_0.entity_type === GuildScheduledEventEntityTypes.STAGE_INSTANCE) {
|
|
c29945_0 = await findOrCreateEventChannel(c26190_0, c26190_1);
|
|
Module38(c29945_0 != null, "could not find or create channel");
|
|
break L13;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
export async function setEventAsActive(c26191_0, c26191_1) {
|
|
let c26191_3;
|
|
let c29946_1, c29946_0, c29946_2, c29946_3, c29946_4, c29946_5, c29946_6;
|
|
L24: {
|
|
L22: {
|
|
L20: {
|
|
c26191_3 = void 0;
|
|
c29946_1 = void 0;
|
|
c29946_0 = c26191_0;
|
|
if (c26191_1 !== void 0) {
|
|
c29946_1 = c26191_1;
|
|
c29946_2 = void 0;
|
|
c29946_3 = void 0;
|
|
c29946_4 = void 0;
|
|
c29946_5 = void 0;
|
|
c29946_6 = void 0;
|
|
} else {
|
|
c29946_1 = false;
|
|
c29946_2 = void 0;
|
|
c29946_3 = void 0;
|
|
c29946_4 = void 0;
|
|
c29946_5 = void 0;
|
|
c29946_6 = void 0;
|
|
}
|
|
await void 0;
|
|
c29946_2 = c29946_0.channel_id;
|
|
c29946_3 = c29946_0.entity_type;
|
|
c29946_4 = c29946_0.name;
|
|
c29946_5 = c29946_0.id;
|
|
c29946_6 = c29946_0.guild_id;
|
|
const r66 = c29946_3;
|
|
if (GuildScheduledEventEntityTypes.STAGE_INSTANCE === r66) {
|
|
Module38(c29946_2 != null, "channel_id is required");
|
|
await startStageInstance(c29946_2, c29946_4, GuildScheduledEventPrivacyLevel.GUILD_ONLY, c29946_1, c29946_5);
|
|
break L24;
|
|
}
|
|
if (GuildScheduledEventEntityTypes.VOICE === r66) {
|
|
Module38(c29946_2 != null, "channel_id is required");
|
|
await GuildScheduledEventsActionCreators.startEvent(c29946_5, c29946_6);
|
|
break L22;
|
|
}
|
|
if (GuildScheduledEventEntityTypes.EXTERNAL === r66) {
|
|
await GuildScheduledEventsActionCreators.startEvent(c29946_5, c29946_6);
|
|
break L20;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|