From 9538a03afb98ddb38903a9bf4cfbacf722aa3f1c Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Mon, 31 Mar 2025 16:54:32 -0500 Subject: [PATCH] feat: uh hahaha you'll see --- .../normalizeInteractionReturnable.tsx | 137 ++++++++---------- .../handlers/chatInputCommand.ts | 68 +++------ packages/bot/src/main.ts | 2 +- packages/core/src/blitzkit/isFunny.ts | 19 ++- 4 files changed, 102 insertions(+), 124 deletions(-) diff --git a/packages/bot/src/core/discord/normalizeInteractionReturnable.tsx b/packages/bot/src/core/discord/normalizeInteractionReturnable.tsx index 015ec3160..76b2c9e10 100644 --- a/packages/bot/src/core/discord/normalizeInteractionReturnable.tsx +++ b/packages/bot/src/core/discord/normalizeInteractionReturnable.tsx @@ -1,4 +1,4 @@ -import { imgur } from '@blitzkit/core'; +import { imgur, isFunny } from '@blitzkit/core'; import { ActionRowBuilder, AttachmentBuilder, @@ -9,7 +9,6 @@ import { MessageEditOptions, } from 'discord.js'; import { InteractionReturnable } from '../../events/interactionCreate'; -import { FunnyType } from '../../events/interactionCreate/handlers/chatInputCommand'; import { theme } from '../../stitches.config'; import { Writeable } from '../../types/writable'; import { jsxToPngThreaded } from '../blitzkit/jsxToPngThreaded'; @@ -17,7 +16,6 @@ import { RenderConfiguration } from '../blitzkit/renderConfiguration'; export async function normalizeInteractionReturnable( returnable: InteractionReturnable, - funnyType?: FunnyType, ) { const images: [number, Buffer][] = []; const reply: InteractionEditReplyOptions & @@ -50,84 +48,75 @@ export async function normalizeInteractionReturnable( } else if (item === null) { return; } else { - let jsx = item; + let jsx: JSX.Element; - switch (funnyType) { - case FunnyType.Rude: { - jsx = ( -
+ {item} + + - {item} -
- ); + /> - break; - } - - case FunnyType.Weird: { - const angle = (Math.random() * 2 - 1) * 10; - jsx = ( -
- {item} + /> - - - - - -
- ); - - break; - } + + + ); + } else { + jsx = ( +
+ {item} +
+ ); } const image = await jsxToPngThreaded(jsx, renderConfiguration); diff --git a/packages/bot/src/events/interactionCreate/handlers/chatInputCommand.ts b/packages/bot/src/events/interactionCreate/handlers/chatInputCommand.ts index 2c879b4de..2c883534a 100644 --- a/packages/bot/src/events/interactionCreate/handlers/chatInputCommand.ts +++ b/packages/bot/src/events/interactionCreate/handlers/chatInputCommand.ts @@ -17,56 +17,34 @@ import { psa } from '../../../core/discord/psa'; import { translator } from '../../../core/localization/translator'; import { Writeable } from '../../../types/writable'; -export enum FunnyType { - Rude, - Weird, -} - -const funnyResponses: Record = { - [FunnyType.Rude]: [ - "Your decisions were calculated, but, man, you're bad at math.", - 'Hey man, have you considered like not lacking?', - 'Let me guess... it was your team?', - 'Confidence is key. Unfortunately, you lost the lock.', - "When I said live green, I wasn't talking about your winrate.", - 'Viewing your stats, publicly? You must be brave.', - 'Bold of you to assume the numbers have gone up since yesterday.', - "I'd give you advice, but I don't think you'd understand.", - "I didn't believe in negative numbers until I saw your stats.", - 'I was gaining hope in humanity. Something changed today.', - "I've seen potatoes aim better than you.", - "I've seen sloths move faster than your tank.", - ], - [FunnyType.Weird]: [ - 'yeah daddy, use me more', - 'uwu, hewe are your swaws... uwu', - 'hehehehe it tickles', - 'yeeeeeeeeeeeeahhhhhh that hits the spot', - 'ooooh yesss my circuits are starting to hurt yeeeeeeee', - ], -}; +const funnyResponses = [ + "your dwecisions were calculawed buw man, you're bad at math 🥀🥀", + 'senpai, have you consiwered not lacking 😳', + 'let shoow a guess cutie... it was your team? 🤬🤬🤬', + 'confiwence is key. unforwunawely you lost whe lock 🔒💔', + "when they say live green, they dwn't mean your 🌳 winrate 🌳", + 'daddy viewing your swats, hewe? you really are brawe 😎', + 'no surrie! your numwers are swill 💔', + "i would giwe you awvice, you won'w understand 🥀🥀", + "i diwn'w beliewe in negawive numwers unwil i saw your stats 😳😳😳", + 'yeah daddy, use me more 🤤', + 'uwu, hewe are your swaws... uwu 😋😋😋', + 'hehehehe it tickles 😻', + 'yeeeeeeeeeeeeahhhhhh that hits the spot 😳', + 'ooooh yesss my circuits are starting to hurt yeeeeeeee 💥', + 'wawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawaw', + 'https://tenor.com/tre3NETle2e.gif', +]; export async function handleChatInputCommand( interaction: ChatInputCommandInteraction, ) { - let funny: FunnyType | undefined = undefined; await interaction.deferReply(); - if (isFunny) { - const funniesLength = Object.keys(funnyResponses).length; - - if (import.meta.env.DEBUG_FUNNY === 'true') { - // in debug mode, just pick a random one - funny = Math.floor(Math.random() * funniesLength); - } else { - const id = BigInt(interaction.user.id); - funny = Number(id % BigInt(funniesLength)); - } - - const responses = funnyResponses[funny]; - const responseIndex = Math.floor(Math.random() * responses.length); - const response = `### ${responses[responseIndex]}`; - const waitTime = response.length * 45; + if (isFunny()) { + const response = + funnyResponses[Math.floor(Math.random() * funnyResponses.length)]; + const waitTime = response.length * 60; await interaction.editReply(response); await new Promise((resolve) => setTimeout(resolve, waitTime)); @@ -92,7 +70,7 @@ export async function handleChatInputCommand( let index = 0; for (const chunk of chunks.filter((chunk) => chunk.length > 0)) { - const reply = await normalizeInteractionReturnable(chunk, funny); + const reply = await normalizeInteractionReturnable(chunk); if ( psa.data && diff --git a/packages/bot/src/main.ts b/packages/bot/src/main.ts index 3ff5f1116..2a030105e 100644 --- a/packages/bot/src/main.ts +++ b/packages/bot/src/main.ts @@ -66,7 +66,7 @@ const interval = setInterval(async () => { for (const guild of client.guilds.cache.values()) { try { const botMember = await guild.members.fetch(client.user.id); - await botMember.setNickname(isFunny ? "No One's Kit" : 'BlitzKit'); + await botMember.setNickname(isFunny ? 'FreakKit' : 'BlitzKit'); } catch {} } }, diff --git a/packages/core/src/blitzkit/isFunny.ts b/packages/core/src/blitzkit/isFunny.ts index 430b2990a..8f1c7b8ad 100644 --- a/packages/core/src/blitzkit/isFunny.ts +++ b/packages/core/src/blitzkit/isFunny.ts @@ -1,4 +1,15 @@ -const now = new Date(); -export const isFunny = - (now.getMonth() === 3 && now.getDate() === 1) || - import.meta.env.DEBUG_FUNNY === 'true'; +const FUNNY_DATES: [number, number][] = [ + // two days for april fools + [4, 1], + [4, 2], +]; + +export function isFunny() { + const now = new Date(); + + return ( + FUNNY_DATES.some( + ([month, day]) => now.getMonth() === month - 1 && now.getDate() === day, + ) || import.meta.env.DEBUG_FUNNY === 'true' + ); +}