Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
conch: Added the conch module
Browse files Browse the repository at this point in the history
  • Loading branch information
Cpt-Dingus committed Aug 5, 2023
1 parent 5d23a33 commit 70b875d
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions src/modules/conch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* @file
* This file contains the 'conch' module definition.
*/


const RESPONSES: string[] = [
"As I see it, yes.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
"Don’t count on it.",
"It is certain.",
"It is decidedly so.",
"Most likely.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Outlook good.",
"Reply hazy, try again.",
"Signs point to yes.",
"Very doubtful.",
"Without a doubt.",
"Yes.",
"Yes – definitely.",
"You may rely on it.",
]

const THUMBNAIL_URL: string = "https://i.imgur.com/vdvGrsR.png"


import { Colors, EmbedBuilder } from 'discord.js';
import * as util from '../core/util.js'

function getRandomReply(): string {

return RESPONSES[Math.floor(Math.random() * RESPONSES.length)]
}

/** Formats a question for the embed, trims it if needed
* @param question The question to format
* @reutrns The formatted question string
*/
function formatQuestion(question: string): string {
question = question.substring(0, 255);
if (!question.endsWith("?")) {
question += "?";
}
return question;
}


/** The root conch command definition */
const conch = new util.RootModule('conch', 'Asks a question to the magic conch (8ball)', [],
[
{
type: util.ModuleOptionType.String,
name: 'question',
description: 'The question to ask',
required: true,
}
],
async (args, interaction) => {
const question: string = args.find(arg => arg.name === 'question')!.value!.toString();

const embed: EmbedBuilder = new EmbedBuilder();

embed.setTitle(formatQuestion(question));
embed.setDescription(getRandomReply());
embed.setColor(Colors.Blurple);
embed.setThumbnail(THUMBNAIL_URL);

await util.replyToInteraction(interaction, {embeds: [embed]});

})

export default conch;

0 comments on commit 70b875d

Please sign in to comment.