import { SlashCommandBuilder } from '@discordjs/builders'; import { CommandInteraction, GuildMember, MessageEmbed } from 'discord.js'; const rand = require('random-seed').create(); const results = [ ['Vigilante', 'Veteran', 'Mafioso', 'Ambusher'], ['Medium', 'Janitor', 'Retributionist'], ['Survivor', 'Vampire Hunter', 'Amnesiac'], ['Spy', 'Blackmailer', 'Jailor'], ['Sheriff', 'Executioner', 'Werewolf'], ['Framer', 'Vampire', 'Jester'], ['Lookout', 'Forger', 'Witch'], ['Escort', 'Transporter', 'Consort', 'Hypnotist'], ['Doctor', 'Disguiser', 'Serial Killer'], ['Investigator', 'Consigliere', 'Mayor'], ['Bodyguard', 'Godfather', 'Arsonist'] ]; function seperate(l: string[]): string { return l.slice(0, -1).join(', ') + ' or ' + l.slice(-1); } module.exports = { data: new SlashCommandBuilder() .setName('investigate') .setDescription('Investigate someone.') .addUserOption((option) => option.setName('who').setDescription('Investigate who?').setRequired(true)) .addBooleanOption((option) => option.setName('sheriff').setDescription('Switch to Sheriff-style investigation').setRequired(false)), execute: async (interaction: CommandInteraction, member: GuildMember) => { const who = interaction.options.getUser('who')!; const sheriff = interaction.options.getBoolean('sheriff'); let response; let color; if (who.id === member.id) { response = 'You decided to investigate yourself tonight. The only thing you\'ve found out this night is that this is a waste of time.'; color = 0x333333; } else { if (sheriff) { rand.seed(who.id); const good = rand.random() > 0.4; if (good) { response = `You decided to investigate **${who.username}** tonight.\n_You cannot find evidence of wrongdoing. Your target seems innocent._`; color = 0x55ff55; } else { response = `You decided to investigate **${who.username}** tonight.\n_Your target is suspicious!_`; color = 0xff3333; } } else { rand.seed(who.id); const result = results[rand.range(results.length)]; response = `You decided to investigate **${who.username}** tonight.\nYour target could be a ${seperate(result.map(r => '**' + r + '**'))}.`; color = 0x444444; } } const embed = new MessageEmbed() .setDescription(response) .setAuthor({ name: `${member.displayName} the ${sheriff ? 'Sheriff' : 'Investigator'}`, iconURL: member.displayAvatarURL() }) .setColor(color); await interaction.reply({ embeds: [embed], ephemeral: true, }); } };