This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d23a33
commit 70b875d
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |