decord/source/modules/guild_scheduled_events/useGuildScheduledEvents.tsx

357 lines
14 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 8928
// Function ID: 8929
2026-07-29 08:29:29 +00:00
// Name: useGuildEvents
2026-08-24 06:08:38 +00:00
// Dependencies: [32, 19, 1391, 1910, 4024, 4374, 8929, 1397, 676, 687, 589, 8822, 8930, 8828, 2]
// Exports: default, getGuildActiveEvent, useActiveEvent, useActiveEventsByChannel, useFirstActiveEventChannel, useGuildActiveEvent, useGuildChannelScheduledEvents, useGuildUpcomingEvents, useGuildUpcomingEventsNotice, useImminentUpcomingGuildEvents
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 8928 (useGuildEvents)
import setDefault from "set" /* 687 */;
import closure_2 from "_slicedToArray" /* 32 */;
import closure_3 from "noop" /* 19 */;
import closure_4 from "ensureGuildLoaded" /* 1391 */;
import closure_5 from "createGuildRecordFromRust" /* 1910 */;
import closure_6 from "getUncachedChannelPermissions" /* 4024 */;
import scheduledEventSort from "scheduledEventSort" /* 4374 */;
import closure_9 from "scheduledEventSort" /* 4374 */;
import closure_10 from "initialize" /* 8929 */;
import GUILD_EVENT_MAX_NAME_LENGTH from "GUILD_EVENT_MAX_NAME_LENGTH" /* 1397 */;
import ME from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-08-24 06:08:38 +00:00
({ isGuildScheduledEventActive: error, StaticGuildEventIndexes: closure_8 } = scheduledEventSort);
2026-07-29 08:29:29 +00:00
({ GuildScheduledEventEntityTypes: unpackModuleId, GuildScheduledEventStatus: closure_12 } = GUILD_EVENT_MAX_NAME_LENGTH);
2026-08-11 06:20:06 +00:00
({ BasicPermissions: map1, GuildFeatures: closure_14 } = ME);
2026-07-20 16:05:17 +00:00
let closure_15 = [];
2026-08-24 06:08:38 +00:00
let closure_16 = 15 * setDefault.Millis.MINUTE;
let result = require("set").fileFinishedImporting("modules/guild_scheduled_events/useGuildScheduledEvents.tsx");
2026-07-20 16:05:17 +00:00
export default function useGuildEvents(arg0, arg1) {
2026-07-23 10:11:24 +00:00
const _require = arg0;
2026-08-24 06:08:38 +00:00
dependencyMap = arg1;
const items = [closure_5, closure_9, closure_6, closure_4];
2026-07-20 16:05:17 +00:00
const items1 = [arg1, arg0];
2026-07-29 08:29:29 +00:00
return _require(589).useStateFromStoresArray(items, () => {
2026-08-24 06:08:38 +00:00
const guild = closure_1_5.getGuild(closure_0);
2026-07-20 16:05:17 +00:00
if (null == guild) {
2026-08-24 06:08:38 +00:00
let found = closure_1_15;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let GUILD_EVENT_UPCOMINGResult = closure_1;
if (closure_1 == null) {
2026-08-24 06:08:38 +00:00
GUILD_EVENT_UPCOMINGResult = closure_1_8.GUILD_EVENT_UPCOMING(guild.id);
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
const guildScheduledEventsByIndex = closure_1_9.getGuildScheduledEventsByIndex(GUILD_EVENT_UPCOMINGResult);
2026-07-20 16:05:17 +00:00
found = guildScheduledEventsByIndex.filter((channel_id) => {
channel_id = channel_id.channel_id;
if (null == channel_id) {
return true;
} else {
2026-08-11 06:20:06 +00:00
basicChannel = basicChannel.getBasicChannel(channel_id);
let canBasicChannelResult = null != basicChannel;
if (canBasicChannelResult) {
2026-08-24 06:08:38 +00:00
canBasicChannelResult = closure_6.canBasicChannel(constants.VIEW_CHANNEL, basicChannel);
2026-08-11 06:20:06 +00:00
}
return canBasicChannelResult;
2026-07-20 16:05:17 +00:00
}
});
}
return found;
}, items1);
};
export const useActiveEvent = function useActiveEvent(id) {
2026-07-23 10:11:24 +00:00
const _require = id;
2026-08-24 06:08:38 +00:00
const items = [closure_9, closure_4, closure_6];
2026-07-20 16:05:17 +00:00
const items1 = [id];
2026-07-29 08:29:29 +00:00
return _require(589).useStateFromStores(items, () => {
2026-08-24 06:08:38 +00:00
const basicChannel = closure_1_4.getBasicChannel(closure_0);
2026-08-11 06:20:06 +00:00
if (null != basicChannel) {
2026-08-24 06:08:38 +00:00
if (closure_1_6.canBasicChannel(closure_1_13.VIEW_CHANNEL, basicChannel)) {
2026-08-11 06:20:06 +00:00
let guild_id;
if (basicChannel != null) {
guild_id = basicChannel.guild_id;
}
if (null == guild_id) {
return null;
} else {
2026-08-24 06:08:38 +00:00
const guildScheduledEventsByIndex = closure_1_9.getGuildScheduledEventsByIndex(closure_1_8.CHANNEL_EVENT_ACTIVE(closure_0));
2026-08-11 06:20:06 +00:00
let first = null;
if (guildScheduledEventsByIndex.length > 0) {
first = guildScheduledEventsByIndex[0];
}
return first;
2026-07-20 16:05:17 +00:00
}
}
}
2026-08-11 06:20:06 +00:00
return null;
2026-07-20 16:05:17 +00:00
}, items1);
};
export const useActiveEventsByChannel = function useActiveEventsByChannel(arg0) {
2026-07-23 10:11:24 +00:00
const _require = arg0;
2026-07-20 16:05:17 +00:00
const items = [closure_9];
const items1 = [arg0];
2026-08-24 06:08:38 +00:00
stateFromStoresArray = _require(stateFromStoresArray[10]).useStateFromStoresArray(items, () => closure_1_9.getGuildScheduledEventsForGuild(closure_0), items1);
2026-07-20 16:05:17 +00:00
const items2 = [stateFromStoresArray];
return React.useMemo(() => {
const map = new Map();
const item = stateFromStoresArray.forEach((channel_id) => {
channel_id = channel_id.channel_id;
if (null != channel_id) {
const result = map.set(channel_id, channel_id);
}
});
return map;
}, items2);
};
2026-07-29 08:29:29 +00:00
export const useGuildUpcomingEvents = function useGuildUpcomingEvents(arg0) {
const _require = arg0;
2026-08-24 06:08:38 +00:00
const items = [closure_9, closure_4, closure_6];
2026-07-29 08:29:29 +00:00
const items1 = [arg0];
return _require(589).useStateFromStoresArray(items, () => {
2026-08-24 06:08:38 +00:00
const guildScheduledEventsByIndex = closure_1_9.getGuildScheduledEventsByIndex(closure_1_8.GUILD_EVENT_UPCOMING(closure_0));
2026-07-29 08:29:29 +00:00
return guildScheduledEventsByIndex.filter((entity_type) => {
if (entity_type.entity_type !== constants.NONE) {
if (entity_type.status === constants2.SCHEDULED) {
if (null == entity_type.channel_id) {
return true;
} else {
2026-08-11 06:20:06 +00:00
basicChannel = basicChannel.getBasicChannel(entity_type.channel_id);
let canBasicChannelResult = null != basicChannel;
if (canBasicChannelResult) {
2026-08-24 06:08:38 +00:00
canBasicChannelResult = closure_6.canBasicChannel(constants3.VIEW_CHANNEL, basicChannel);
2026-08-11 06:20:06 +00:00
}
return canBasicChannelResult;
2026-07-29 08:29:29 +00:00
}
}
}
return false;
});
}, items1);
};
2026-07-20 16:05:17 +00:00
export const useGuildUpcomingEventsNotice = function useGuildUpcomingEventsNotice(arg0) {
let nextShownUpcomingEventNoticeType;
let tmp8;
2026-07-23 10:11:24 +00:00
const _require = arg0;
2026-07-29 08:29:29 +00:00
let obj = _require(stateFromStoresArray[10]);
2026-08-24 06:08:38 +00:00
const items = [closure_9, closure_4, closure_6];
2026-07-29 08:29:29 +00:00
const items1 = [arg0];
stateFromStoresArray = obj.useStateFromStoresArray(items, () => {
2026-08-24 06:08:38 +00:00
const guildScheduledEventsByIndex = closure_1_9.getGuildScheduledEventsByIndex(closure_1_8.GUILD_EVENT_UPCOMING(closure_0));
2026-07-29 08:29:29 +00:00
return guildScheduledEventsByIndex.filter((entity_type) => {
if (entity_type.entity_type !== constants.NONE) {
if (entity_type.status === constants2.SCHEDULED) {
if (null == entity_type.channel_id) {
return true;
} else {
2026-08-11 06:20:06 +00:00
basicChannel = basicChannel.getBasicChannel(entity_type.channel_id);
let canBasicChannelResult = null != basicChannel;
if (canBasicChannelResult) {
2026-08-24 06:08:38 +00:00
canBasicChannelResult = closure_6.canBasicChannel(constants3.VIEW_CHANNEL, basicChannel);
2026-08-11 06:20:06 +00:00
}
return canBasicChannelResult;
2026-07-29 08:29:29 +00:00
}
}
}
return false;
});
}, items1);
2026-08-24 06:08:38 +00:00
const items2 = [closure_10];
2026-07-29 08:29:29 +00:00
const stateFromStoresObject = _require(stateFromStoresArray[10]).useStateFromStoresObject(items2, () => store.getAllEventDismissals());
const obj2 = _require(stateFromStoresArray[10]);
2026-08-24 06:08:38 +00:00
const items3 = [closure_10];
2026-07-29 08:29:29 +00:00
const stateFromStoresObject1 = _require(stateFromStoresArray[10]).useStateFromStoresObject(items3, () => store.getAllUpcomingNoticeSeenTimes());
const obj3 = _require(stateFromStoresArray[10]);
const items4 = [closure_9];
const items5 = [stateFromStoresArray];
const stateFromStoresObject2 = _require(stateFromStoresArray[10]).useStateFromStoresObject(items4, () => {
if (null == stateFromStoresArray) {
2026-07-20 16:05:17 +00:00
let reduced = {};
} else {
2026-07-29 08:29:29 +00:00
reduced = stateFromStoresArray.reduce((arg0, id) => {
let obj = callback(table[11]);
2026-07-20 16:05:17 +00:00
obj = {};
const nextRecurrenceIdInEvent = obj.getNextRecurrenceIdInEvent(id);
const merged = Object.assign(arg0);
2026-07-29 08:29:29 +00:00
obj[id.id] = interestedInEventRecurrence.isInterestedInEventRecurrence(id.id, nextRecurrenceIdInEvent);
2026-07-20 16:05:17 +00:00
return obj;
}, {});
}
return reduced;
2026-07-29 08:29:29 +00:00
}, items5);
const obj4 = _require(stateFromStoresArray[10]);
2026-08-24 06:08:38 +00:00
const items6 = [closure_5];
const stateFromStores = _require(stateFromStoresArray[10]).useStateFromStores(items6, () => closure_1_5.getGuild(closure_0));
2026-07-20 16:05:17 +00:00
let hasItem = null != stateFromStores;
if (hasItem) {
const features = stateFromStores.features;
hasItem = !features.has(constants.COMMUNITY);
}
if (hasItem) {
const features2 = stateFromStores.features;
hasItem = features2.has(constants.INTERNAL_EMPLOYEE_ONLY);
}
2026-07-29 08:29:29 +00:00
if (null != stateFromStoresArray) {
2026-07-20 16:05:17 +00:00
if (null != stateFromStoresObject2) {
if (hasItem) {
let num = 0;
2026-07-29 08:29:29 +00:00
if (0 < stateFromStoresArray.length) {
2026-07-20 16:05:17 +00:00
while (true) {
2026-07-29 08:29:29 +00:00
tmp8 = stateFromStoresArray[num];
2026-07-20 16:05:17 +00:00
let tmp9 = stateFromStoresObject[tmp8.id];
let tmp10 = stateFromStoresObject1[tmp8.id];
2026-07-29 08:29:29 +00:00
let flag = stateFromStoresObject2[tmp8.id];
let tmp11 = num;
if (flag == null) {
flag = false;
}
let tmp12 = _require;
let tmp13 = stateFromStoresArray;
let obj6 = _require(stateFromStoresArray[12]);
let tmp14 = obj6;
let tmp15 = tmp8;
let tmp16 = tmp9;
let tmp17 = tmp10;
let tmp18 = flag;
nextShownUpcomingEventNoticeType = obj6.getNextShownUpcomingEventNoticeType(tmp8, tmp9, tmp10, flag);
2026-07-20 16:05:17 +00:00
if (null != nextShownUpcomingEventNoticeType) {
break;
} else {
num = num + 1;
}
}
2026-07-29 08:29:29 +00:00
obj = { upcomingEvent: null, noticeType: null };
obj[0] = tmp8;
obj[1] = nextShownUpcomingEventNoticeType;
2026-07-20 16:05:17 +00:00
return obj;
}
}
}
}
};
2026-08-24 06:08:38 +00:00
export const getGuildActiveEvent = function getGuildActiveEvent(closure_0) {
let obj = arg1;
if (arg1 === undefined) {
obj = closure_9;
}
let tmp = arg2;
if (arg2 === undefined) {
tmp = closure_4;
}
closure_0 = tmp;
let tmp2 = arg3;
if (arg3 === undefined) {
tmp2 = closure_6;
}
closure_1 = tmp2;
const guildScheduledEventsByIndex = obj.getGuildScheduledEventsByIndex(closure_8.GUILD_EVENT_ACTIVE(closure_0));
return guildScheduledEventsByIndex.find((entity_type) => {
if (entity_type.entity_type !== closure_1_11.NONE) {
if (closure_1_7(entity_type)) {
if (null == entity_type.channel_id) {
return true;
} else {
basicChannel = basicChannel.getBasicChannel(entity_type.channel_id);
let canBasicChannelResult = null != basicChannel;
if (canBasicChannelResult) {
canBasicChannelResult = closure_1.canBasicChannel(closure_1_13.VIEW_CHANNEL, basicChannel);
}
return canBasicChannelResult;
}
}
}
return false;
});
};
2026-07-20 16:05:17 +00:00
export const useGuildActiveEvent = function useGuildActiveEvent(guild_id) {
2026-07-23 10:11:24 +00:00
const _require = guild_id;
2026-08-24 06:08:38 +00:00
const items = [closure_9, closure_4, closure_6];
2026-07-20 16:05:17 +00:00
const items1 = [guild_id];
2026-07-29 08:29:29 +00:00
return _require(589).useStateFromStores(items, () => {
2026-08-24 06:08:38 +00:00
if (closure_1_9 !== undefined) {
if (tmp2 !== undefined) {
closure_0 = tmp2;
if (tmp3 !== undefined) {
closure_1 = tmp3;
const guildScheduledEventsByIndex = closure_1_9.getGuildScheduledEventsByIndex(closure_1_8.GUILD_EVENT_ACTIVE(tmp));
return guildScheduledEventsByIndex.find((entity_type) => {
if (entity_type.entity_type !== closure_1_11.NONE) {
if (closure_1_7(entity_type)) {
if (null == entity_type.channel_id) {
return true;
} else {
basicChannel = basicChannel.getBasicChannel(entity_type.channel_id);
let canBasicChannelResult = null != basicChannel;
if (canBasicChannelResult) {
canBasicChannelResult = closure_1.canBasicChannel(closure_1_13.VIEW_CHANNEL, basicChannel);
}
return canBasicChannelResult;
}
}
2026-08-11 06:20:06 +00:00
}
2026-08-24 06:08:38 +00:00
return false;
});
2026-07-20 16:05:17 +00:00
}
}
2026-08-24 06:08:38 +00:00
}
2026-07-20 16:05:17 +00:00
}, items1);
};
export const useGuildChannelScheduledEvents = function useGuildChannelScheduledEvents(id) {
2026-07-23 10:11:24 +00:00
const _require = id;
2026-07-20 16:05:17 +00:00
const items = [closure_9];
const items1 = [id];
2026-08-24 06:08:38 +00:00
return _require(589).useStateFromStores(items, () => closure_1_9.getGuildScheduledEventsByIndex(closure_1_8.CHANNEL_EVENT_UPCOMING(closure_0)), items1);
2026-07-20 16:05:17 +00:00
};
export const useFirstActiveEventChannel = function useFirstActiveEventChannel(id) {
2026-07-23 10:11:24 +00:00
const _require = id;
2026-08-24 06:08:38 +00:00
const items = [closure_4, closure_9];
2026-07-20 16:05:17 +00:00
const items1 = [id];
2026-07-29 08:29:29 +00:00
return _require(589).useStateFromStores(items, () => {
2026-08-24 06:08:38 +00:00
const guildScheduledEventsByIndex = closure_1_9.getGuildScheduledEventsByIndex(closure_1_8.GUILD_EVENT_ACTIVE(closure_0));
2026-07-29 08:29:29 +00:00
const found = guildScheduledEventsByIndex.find((channel_id) => null != channel.getChannel(channel_id.channel_id));
2026-07-20 16:05:17 +00:00
let channel_id;
2026-07-29 08:29:29 +00:00
if (found != null) {
2026-07-20 16:05:17 +00:00
channel_id = found.channel_id;
}
2026-08-24 06:08:38 +00:00
return closure_1_4.getChannel(channel_id);
2026-07-20 16:05:17 +00:00
}, items1);
};
export const useImminentUpcomingGuildEvents = function useImminentUpcomingGuildEvents(id) {
2026-07-23 10:11:24 +00:00
const _require = id;
[tmp2, dependencyMap] = stateFromStores(React.useState(() => Date.now()), 2);
2026-07-20 16:05:17 +00:00
const effect = React.useEffect(() => {
const interval = setInterval(() => {
2026-07-29 08:29:29 +00:00
callback(Date.now());
2026-08-24 06:08:38 +00:00
}, closure_1_16);
2026-07-20 16:05:17 +00:00
return () => clearInterval(closure_0);
}, []);
2026-07-23 10:11:24 +00:00
const tmp = stateFromStores(React.useState(() => Date.now()), 2);
let items = [closure_9];
2026-07-20 16:05:17 +00:00
const items1 = [id, tmp2];
2026-07-29 08:29:29 +00:00
stateFromStores = _require(589).useStateFromStores(items, () => {
2026-07-23 10:11:24 +00:00
if (null == closure_0) {
2026-07-20 16:05:17 +00:00
let items = [];
} else {
2026-08-24 06:08:38 +00:00
items = closure_1_9.getGuildScheduledEventsByIndex(closure_1_8.CHANNEL_EVENT_UPCOMING(tmp));
2026-07-20 16:05:17 +00:00
}
return items;
}, items1);
const items2 = [stateFromStores];
return React.useMemo(() => stateFromStores.filter((status) => {
2026-08-24 06:08:38 +00:00
const eventSchedule = callback(8828).getEventSchedule(status);
2026-07-20 16:05:17 +00:00
({ startTime, endTime } = eventSchedule);
2026-08-24 06:08:38 +00:00
const obj = callback(8828);
2026-07-29 08:29:29 +00:00
let toISOStringResult1;
2026-08-24 06:08:38 +00:00
const obj2 = callback(8822);
2026-07-29 08:29:29 +00:00
if (endTime != null) {
2026-07-20 16:05:17 +00:00
toISOStringResult1 = endTime.toISOString();
}
const eventTimeData = obj2.getEventTimeData(startTime.toISOString(), toISOStringResult1);
2026-07-29 08:29:29 +00:00
let withinStartWindow = status.status !== constants.ACTIVE;
2026-07-20 16:05:17 +00:00
if (withinStartWindow) {
withinStartWindow = eventTimeData.withinStartWindow;
}
if (withinStartWindow) {
withinStartWindow = eventTimeData.diffMinutes < 15;
}
return withinStartWindow;
}), items2);
};