1112// Calculate days in a month, accounting for leap years
13function getDaysInMonth(year: number, month: number): number {
14return new Date(year, month, 0).getDate();
15}
1617// Format date as MM-DD
18function formatDate(date: Date): string {
19return `${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
20}
2122// Calculate the date range for the first half of next month
23function calculateFirstHalfNextMonth(): { startDate: string; endDate: string; rangeText: string } {
24const now = new Date();
2546}
4748// Main function that runs as a scheduled val for first half
49export default async function() {
50console.log("🕒 First Half Map Vote Cron Job started");
51
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};
4546// Enhanced Discord API request function with rate limiting
47async function discordRequest(endpoint: string, options: RequestInit = {}) {
48const token = Deno.env.get("DISCORD_BOT_TOKEN");
49if (!token) {
102103// Add emoji reaction to message - RATE LIMITED VERSION
104async function addReaction(channelId: string, messageId: string, emoji: string) {
105const routeKey = `/channels/${channelId}/messages/${messageId}/reactions`;
106132}
133134// Helper function to convert color name to integer value
135function getColorFromString(colorName: string): number {
136const colorMap: Record<string, number> = {
137"Red": 0xED4245,
151152// Create the vote channel in Discord
153async function createVoteChannel(config: CurrentConfig, remainder: string = "") {
154try {
155const { DiscordTargets, ApplicationPersonalization } = config;
232233// Send initial placeholder embed
234async function sendInitialEmbed(channel: any, initialEmbedData: InitialVoteCreationEmbedData) {
235try {
236const embed = {
272273// Process variants for a map and add emoji reactions
274async function processMapVariants(messageId: string, channelId: string, map: MapInfo, variantOptions: any) {
275const mapMetaVariants: string[] = [];
276const mapEnabledVariants: string[] = [];
388389// Populate channel with map options and add reactions
390async function populateChannelWithMaps(
391channel: any,
392mapData: HellLetLooseMapData,
459460// Finalize bookend embeds
461async function finalizeBotBookends(
462channel: any,
463initialMessage: any,
569570// Create discussion thread
571async function createDiscussionThread(
572channel: any,
573metaVariants: string[],
622}
623624// Main function - entry point for cron job
625export default async function(remainder: string = "") {
626console.log("🚀 Starting Map Vote Channel Creation");
627const startTime = Date.now();
643};
644645// Load all other required data using getter functions
646const mapData = getHellLetLooseMapData();
647const alphabetImages = getAlphabetImageUrls();
2import { useState } from "https://esm.sh/react@18.2.0";
34export function App() {
5const [clicked, setClicked] = useState(0);
6return (
9const LOCK_TIMEOUT = 15 * 60 * 1000;
1011// Main function that runs as a scheduled val
12export default async function() {
13console.log("🕒 Map Vote Cron Job started");
14109}
110111// Utility function to clear the lock manually if needed
112export async function clearLock() {
113try {
114await blob.delete("is_creating_map_vote");
crypto-geminiscript.tsx2 matches
57const FNG_API_URL = "https://api.alternative.me/fng/?limit=1";
5859async function fetchFromApi<T>(url: string, isCoinGecko: boolean = true): Promise<T | null> {
60const headers: HeadersInit = {};
61if (isCoinGecko && COINGECKO_API_KEY) {
78}
7980export default async function(req: Request): Promise<Response> {
81// Set CORS headers to allow requests from any origin (or restrict to your frontend's domain)
82// For development, '*' is fine. For production, specify your frontend's origin.
27}
28// Get current configuration from hardcoded values
29export function getCurrentConfig() {
30try {
31const config = {
4243// Get completed vote bookend embed data
44export function getCompletedVoteBookendEmbedData(): CompletedVoteCreationBookendEmbedData {
45return {
46topBookend: {
23}
2425export function getHellLetLooseMapData(): HellLetLooseMapData {
26return {
27Maps: [
1213// Get initial embed data
14export function getInitialEmbedData(): InitialVoteCreationEmbedData {
15return {
16InitialEmbedTitle: "Loading . . .",