2023-11-16 11:33:11 +01:00
import { GuildMember , SlashCommandBuilder , CommandInteraction , messageLink , User } from 'discord.js' ;
2023-10-29 12:10:13 +01:00
import { getTextResponsePrettyPlease , sendSegments , startGame } from '../lib/game' ;
2023-10-29 10:22:23 +01:00
import { shuffle } from 'd3-array' ;
2023-11-16 11:33:11 +01:00
import { Command } from '../types/index' ;
2023-10-29 10:22:23 +01:00
2023-10-29 12:10:13 +01:00
const horrorStarters = [
'I was playing with my boobs.' ,
'Bird 1: Uh oh.' ,
'My girlfriend smirked as she waved the positive pregnancy test in my face.' ,
'I cum in the sink.' ,
'My girlfriend had dementia and was slowly regaining her memories.' ,
'"You are what you eat." said the blue fairy unwisely.' ,
'Just saw the FNAF movie...' ,
'After rubbing the lamp, I wished for a million bucks.' ,
'math teacher: the boat is 50 feet long.' ,
'I am petrified of water, even drinking it terrifies me.' ,
'I heard my wife knock on the bathroom door.' ,
'"God isnt real!" Said the atheist.' ,
'I was walking to my local Waffle House.' ,
'Knowing I have intense feet fetish, my wife surprised me last night with her lovely feet in view as I entered the room.' ,
'I was playing with my big boobs then I remembered.' ,
'As per routing, I put my headphones on and a video of an anime girl doing ear-licking ASMR to help me to bed.' ,
'My grandma has 206 bones in her body.' ,
'"You dont have object permanence" said the doctor.' ,
'I saw a kid at my school not stand up for the National Anthem.' ,
'After my one-night stand with the mysterious beauty, my penis began to itch and ache terribly.' ,
'I went werewolf hunting for the first time.' ,
'"For my first wish" he said, "I want to be a girl!".' ,
'When she found the man starving and on the brink of death, she had only one thing to offer - her still lactating breast' ,
'"Girl dont have penises," I said confidently.' ,
'I was grabbing a quick midnight snack, but that\'s when I saw him.' ,
'I was about to make out with a woman untill...' ,
'My eyes widened in shock and horror as I watched my son tear open his Christmas present.' ,
'I hate being virgin.' ,
'Obama was elected president...' ,
'I went into my first day as a police officer happy, as could be.' ,
'why does peopl like to call joe bidet "sleepy joe"...' ,
'My boss exploded.' ,
'As I lay naked strapped to bed, i couldn\'t wait till my husband came back home.' ,
'There are two trans girl inside a wolf.' ,
'This morning, I woke up left-handed.' ,
'I prayed to God for me to not have a sleep paralysis demon on top of me every night.'
] ;
async function getContinuation ( player : User , i : number , halves : string [ ] , backwards = false ) {
const currentHalf = halves [ i ] ;
let nextHalf = await getTextResponsePrettyPlease (
player ,
` > _ ${ currentHalf } _ \ n ${ backwards ? 'What would this sentence be **preceeded by**? (Write the first sentence.)' : '**Continue** this sentence with a twist!' } ` ,
( msg ) = > ! ( msg . includes ( '. ' ) || msg . includes ( '! ' ) || msg . includes ( '? ' ) )
) ;
if ( ! ( nextHalf . endsWith ( '.' ) || nextHalf . endsWith ( '!' ) || nextHalf . endsWith ( '?' ) ) ) nextHalf = nextHalf + '.' ;
return nextHalf ;
}
function shift < T > ( arr : T [ ] ) : T [ ] {
return [ . . . arr . slice ( 1 ) , arr [ 0 ] ] ;
}
2023-11-16 11:33:11 +01:00
export default {
2023-10-29 10:22:23 +01:00
data : new SlashCommandBuilder ( )
. setName ( 'twosentencehorror' )
. setDescription ( 'Communally create the worst horror stories known to man' ) ,
2023-11-16 11:33:11 +01:00
execute : async ( interaction : CommandInteraction ) = > {
2023-10-29 10:22:23 +01:00
if ( ! interaction . isChatInputCommand ( ) ) return ;
2023-11-16 11:33:11 +01:00
const member = interaction . member ! as GuildMember ;
2023-10-29 10:22:23 +01:00
2023-10-29 11:11:07 +01:00
startGame ( interaction , member . user , 'Two Sentence Horror' , async ( players , channel ) = > {
2023-10-29 12:10:13 +01:00
players = shuffle ( players ) ;
2023-10-29 10:22:23 +01:00
2023-10-29 12:10:13 +01:00
const initialHalves = shuffle ( horrorStarters ) . slice ( 0 , players . length ) ;
2023-10-29 10:22:23 +01:00
2023-10-29 12:10:13 +01:00
// bottom branch
const secondHalves1 = await Promise . all ( players . map ( ( player , i ) = > getContinuation ( player , i , initialHalves , false ) ) ) ;
players = shift ( players ) ;
// bottom branch
const firstHalves1 = await Promise . all ( players . map ( ( player , i ) = > getContinuation ( player , i , secondHalves1 , true ) ) ) ;
players = shift ( players ) ;
// top branch
const secondHalves2 = await Promise . all ( players . map ( ( player , i ) = > getContinuation ( player , i , initialHalves , false ) ) ) ;
players = shift ( players ) ;
// top branch
const firstHalves2 = await Promise . all ( players . map ( ( player , i ) = > getContinuation ( player , i , secondHalves2 , true ) ) ) ;
players = shift ( players ) ;
// bottom branch
const secondHalves1Alt = await Promise . all ( players . map ( ( player , i ) = > getContinuation ( player , i , firstHalves2 , false ) ) ) ;
players = shift ( players ) ;
2023-10-29 10:22:23 +01:00
2023-10-29 12:10:13 +01:00
const pairs = [
[ initialHalves , secondHalves1Alt ] ,
[ firstHalves2 , secondHalves1 ] ,
[ firstHalves1 , secondHalves2 ]
] . flatMap ( ( [ firstHalves , secondHalves ] ) = > firstHalves . map ( ( first , i ) = > first + ' ' + secondHalves [ i ] ) ) ;
2023-10-29 10:22:23 +01:00
const segments = [
2023-10-29 11:11:07 +01:00
'Here\'s the bone-chilling stories you\'ve all created:\n' ,
2023-10-29 12:10:13 +01:00
. . . pairs . map ( sentences = > ` - ${ sentences } ` ) ,
2023-10-29 11:11:07 +01:00
'\nThank you for participating :)'
2023-10-29 10:22:23 +01:00
] ;
2023-10-29 11:11:07 +01:00
const messages = await sendSegments ( segments , channel ) ;
players . forEach ( player = > {
player . send ( ` **The game has concluded!** See your results here: ${ messageLink ( messages [ 0 ] . channelId , messages [ 0 ] . id ) } ` ) ;
} ) ;
2023-10-29 10:22:23 +01:00
} ) ;
}
2023-11-16 11:33:11 +01:00
} satisfies Command ;