112 lines
5.1 KiB
TypeScript
112 lines
5.1 KiB
TypeScript
import { GuildMember, SlashCommandBuilder, CommandInteraction, messageLink, User } from 'discord.js';
|
|
import { getTextResponsePrettyPlease, sendSegments, startGame } from '../lib/game';
|
|
import { shuffle } from 'd3-array';
|
|
import { Command } from '../types/index';
|
|
|
|
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]];
|
|
}
|
|
|
|
export default {
|
|
data: new SlashCommandBuilder()
|
|
.setName('twosentencehorror')
|
|
.setDescription('Communally create the worst horror stories known to man'),
|
|
|
|
execute: async (interaction: CommandInteraction) => {
|
|
if (!interaction.isChatInputCommand()) return;
|
|
|
|
const member = interaction.member! as GuildMember;
|
|
|
|
startGame(interaction, member.user, 'Two Sentence Horror', async (players, channel) => {
|
|
players = shuffle(players);
|
|
|
|
const initialHalves = shuffle(horrorStarters).slice(0, players.length);
|
|
|
|
// 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);
|
|
|
|
const pairs = [
|
|
[initialHalves, secondHalves1Alt],
|
|
[firstHalves2, secondHalves1],
|
|
[firstHalves1, secondHalves2]
|
|
].flatMap(([firstHalves, secondHalves]) => firstHalves.map((first, i) => first + ' ' + secondHalves[i]));
|
|
|
|
const segments = [
|
|
'Here\'s the bone-chilling stories you\'ve all created:\n',
|
|
...pairs.map(sentences => `- ${sentences}`),
|
|
'\nThank you for participating :)'
|
|
];
|
|
|
|
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)}`);
|
|
});
|
|
});
|
|
}
|
|
} satisfies Command; |