1// Map Vote Channel Creator with enhanced rate limit handling
2// This is the main function that will be scheduled as a cron job
3import { DiscordRateLimitService } from "https://esm.town/v/ktodaz/Discord_Bot_Services/discord-rate-limit-service.tsx";
4import { getAlphabetImageUrls } from "https://esm.town/v/ktodaz/Discord_Bot_Services/map_vote/map-vote-getAlphabetImageUrls.tsx";
44};
45
46// Enhanced Discord API request function with rate limiting
47async function discordRequest(endpoint: string, options: RequestInit = {}) {
48 const token = Deno.env.get("DISCORD_BOT_TOKEN");
49 if (!token) {
102
103// Add emoji reaction to message - RATE LIMITED VERSION
104async function addReaction(channelId: string, messageId: string, emoji: string) {
105 const routeKey = `/channels/${channelId}/messages/${messageId}/reactions`;
106
132}
133
134// Helper function to convert color name to integer value
135function getColorFromString(colorName: string): number {
136 const colorMap: Record<string, number> = {
137 "Red": 0xED4245,
151
152// Create the vote channel in Discord
153async function createVoteChannel(config: CurrentConfig, remainder: string = "") {
154 try {
155 const { DiscordTargets, ApplicationPersonalization } = config;
232
233// Send initial placeholder embed
234async function sendInitialEmbed(channel: any, initialEmbedData: InitialVoteCreationEmbedData) {
235 try {
236 const embed = {
272
273// Process variants for a map and add emoji reactions
274async function processMapVariants(messageId: string, channelId: string, map: MapInfo, variantOptions: any) {
275 const mapMetaVariants: string[] = [];
276 const mapEnabledVariants: string[] = [];
388
389// Populate channel with map options and add reactions
390async function populateChannelWithMaps(
391 channel: any,
392 mapData: HellLetLooseMapData,
459
460// Finalize bookend embeds
461async function finalizeBotBookends(
462 channel: any,
463 initialMessage: any,
569
570// Create discussion thread
571async function createDiscussionThread(
572 channel: any,
573 metaVariants: string[],
622}
623
624// Main function - entry point for cron job
625export default async function(remainder: string = "") {
626 console.log("🚀 Starting Map Vote Channel Creation");
627 const startTime = Date.now();
643 };
644
645 // Load all other required data using getter functions
646 const mapData = getHellLetLooseMapData();
647 const alphabetImages = getAlphabetImageUrls();