8const CREATION_LOCK_KEY = "map_vote_creation_first_half";
910// Basic Discord request function with rate limiting
11async function safeDiscordRequest(endpoint: string, options: RequestInit = {}) {
12const token = Deno.env.get("DISCORD_BOT_TOKEN");
1343}
4445// Simplified test function that just checks channel access
46async function testChannelAccess(channelId: string) {
47try {
48console.log(`Testing access to channel ${channelId}`);
73}
7475// Main function
76export default async function() {
77console.log("🧪 SIMPLE TEST: Map Vote Tally Channel Access Test");
78
untitled-4783main.js10 matches
1516// --- INITIALIZATION ---
17function init() {
18// Scene
19scene = new THREE.Scene();
77}
7879function addBuilding(x, y, z, width, height, depth, color) {
80const geometry = new THREE.BoxGeometry(width, height, depth);
81const material = new THREE.MeshStandardMaterial({ color: color });
8687// --- GAME LOOP & UPDATES ---
88function animate(currentTime) {
89if (gameOver) {
90scoreElement.innerText = `GAME OVER! Survived: ${Math.floor(gameTime / 1000)}s\nPress R to Restart`;
114let lastFrameTime = 0;
115116function handlePlayerMovement() {
117const moveDirection = new THREE.Vector3();
118const rotationSpeed = playerTurnSpeed;
143}
144145function updateCamera() {
146const offset = new THREE.Vector3(0, 3, -6); // Camera offset from player
147offset.applyQuaternion(player.quaternion); // Apply player's rotation to offset
150}
151152function spawnCars(currentTime) {
153if (currentTime - lastCarSpawnTime > CAR_SPAWN_INTERVAL) {
154lastCarSpawnTime = currentTime;
179}
180181function updateCars() {
182cars.forEach((car, index) => {
183car.position.z += car.userData.directionZ * car.userData.speed;
191}
192193function checkCollisions() {
194const playerBox = new THREE.Box3().setFromObject(player);
195cars.forEach(car => {
204}
205206function restartGame() {
207gameOver = false;
208gameTime = 0;
220221// --- UTILITIES ---
222function onWindowResize() {
223camera.aspect = window.innerWidth / window.innerHeight;
224camera.updateProjectionMatrix();
luciaMagicLinkStartermagic-links.ts3 matches
56// Create a magic link token for the given email
7export async function createMagicLinkToken(userEmail: string): Promise<string> {
8const token = generateSessionToken();
9const now = Math.floor(Date.now() / 1000);
1920// Send a magic link email
21export async function sendMagicLinkEmail(url: string, userEmail: string, token: string): Promise<boolean> {
22try {
23const magicLink = `${url}/auth/magic-link/${token}`;
4748// Validate a magic link token and create a session
49export async function validateMagicLinkToken(token: string): Promise<{ valid: boolean; userId?: number }> {
50const now = Math.floor(Date.now() / 1000);
51
11const CREATION_LOCK_KEY = "map_vote_creation_first_half";
1213// Main function that runs as a scheduled val for tallying votes (testing version)
14export default async function() {
15console.log("🧪 TEST MODE: First Half Map Vote Tally Test Job started");
16console.log("⚠️ WARNING: This version skips time verification and is for testing only!");
86const tallyStartTime = Date.now();
8788// Call the map vote tallying function
89const tallyResult = await mapVoteTallying(channelId);
90
12const MINIMUM_VOTING_PERIOD_MS = 3 * 24 * 60 * 60 * 1000; // 3 days in milliseconds
1314// Main function that runs as a scheduled val for tallying second half votes
15export default async function() {
16console.log("🕒 Second Half Map Vote Tally Cron Job started");
17111const tallyStartTime = Date.now();
112113// Call the map vote tallying function
114const tallyResult = await mapVoteTallying(channelId);
115
12const MINIMUM_VOTING_PERIOD_MS = 3 * 24 * 60 * 60 * 1000; // 3 days in milliseconds
1314// Main function that runs as a scheduled val for tallying votes
15export default async function() {
16console.log("🕒 Map Vote Tally Cron Job started");
17110const tallyStartTime = Date.now();
111112// Call the map vote tallying function
113const tallyResult = await mapVoteTallying(channelId);
114
TowniePreviewFrame.tsx4 matches
9}
1011export function PreviewFrame(props: PreviewProps) {
12const previewKey = useRef<string>("new-chat");
13const [count, setCount] = useState<number>(0);
73const TSRE = /\/$/;
7475function URLInput({ url, pathname, setPathname }) {
76const prefix = url.replace(TSRE, "");
77return (
90}
9192function PreviewSelect({ index, setIndex, files }) {
93return (
94<div>
116}
117118function usePreviewURL({ files }) {
119const [index, setIndex] = useState<number>(0);
120const htmlVals = files?.filter(file => file.links?.endpoint !== undefined);
326this.updateRateLimitFromException(routeKey, retryAfter);
327328// Check if retry time would exceed the function timeout
329const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes (to stay safely under 10 min limit)
330if (retryAfter * 1000 > MAX_WAIT_TIME) {
331console.log(`⚠️ Retry time (${retryAfter}s) would exceed function timeout.`);
332console.log(`Saving state to blob and failing with suggestion to retry later.`);
333336337throw new Error(
338`Rate limit retry time (${retryAfter}s) exceeds function timeout. `
339+ `Please try again later. State has been saved to resume properly.`,
340);
367const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes
368if ((this.globalRateLimitUntil - Date.now()) > MAX_WAIT_TIME) {
369console.log(`⚠️ Global rate limit wait time (${waitTime}s) would exceed function timeout.`);
370console.log(`Saving state and failing with suggestion to retry later.`);
371374375throw new Error(
376`Global rate limit wait time (${waitTime}s) exceeds function timeout. `
377+ `Please try again later. State has been saved to resume properly.`,
378);
616console.log(`Rate limit exhausted for route ${routeKey}. Waiting ${waitTimeWithBuffer}ms until reset.`);
617618// Check if wait time would exceed the function timeout
619const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes
620if (waitTimeWithBuffer > MAX_WAIT_TIME) {
621console.log(`⚠️ Wait time (${waitTimeWithBuffer}ms) would exceed function timeout.`);
622console.log(`Saving state and failing with suggestion to retry later.`);
623626627throw new Error(
628`Rate limit wait time exceeds function timeout. `
629+ `Please try again later. State has been saved to resume properly.`,
630);
672console.log(`Global rate limit window full. Waiting ${waitTime}ms for a slot to open.`);
673674// Check if wait time would exceed the function timeout
675const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes
676if (waitTime > MAX_WAIT_TIME) {
677console.log(`⚠️ Global rate limit wait time (${waitTime}ms) would exceed function timeout.`);
678console.log(`Saving state and failing with suggestion to retry later.`);
679682683throw new Error(
684`Global rate limit wait time exceeds function timeout. `
685+ `Please try again later. State has been saved to resume properly.`,
686);
692}
693694// Helper function to create a delay
695private delay(ms: number): Promise<void> {
696return new Promise(resolve => setTimeout(resolve, ms));
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 second half of current month
23function calculateSecondHalfCurrentMonth(): { startDate: string; endDate: string; rangeText: string } {
24const now = new Date();
25const year = now.getFullYear();
40}
4142// Main function that runs as a scheduled val for second half
43export default async function() {
44console.log("🕒 Second Half Map Vote Cron Job started");
45
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