From 03935a0cee8e99db1fc3b98cbc8a28e5e10be688 Mon Sep 17 00:00:00 2001
From: Caleb Fontenot <foley2431@gmail.com>
Date: Tue, 4 Apr 2023 17:20:28 -0500
Subject: [PATCH] Add countChars function

---
 commands/addPhrase.ts   |  2 +-
 commands/countChars.ts  | 26 +++++++++++++-------------
 commands/listPhrases.ts |  6 +++---
 commands/ping.ts        |  4 ++--
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/commands/addPhrase.ts b/commands/addPhrase.ts
index 37ff897..6e4e0c6 100644
--- a/commands/addPhrase.ts
+++ b/commands/addPhrase.ts
@@ -18,7 +18,7 @@ module.exports = {
 			.setDescription("The phrase that the abbreviation shortens")
 			.setRequired(true)
 			),
-	async execute(interaction) {
+	async execute(interaction, client) {
 		var abbreviation = interaction.options.getString('abbreviation').toLowerCase();
 		var phrase = interaction.options.getString('phrase');
 		await interaction.reply('Adding abbreviation `' + abbreviation + "` to target list. This will complete to the phrase `" + phrase + "`");
diff --git a/commands/countChars.ts b/commands/countChars.ts
index e4a0bd2..ac10779 100644
--- a/commands/countChars.ts
+++ b/commands/countChars.ts
@@ -4,19 +4,19 @@ module.exports = {
 	data: new SlashCommandBuilder()
 		.setName('count_chars')
 		.setDescription('Counts the number of characters in a string')
-		.addStringOption( option =>
+		.addStringOption(option =>
 			option.setName('string')
-			.setDescription("String to count characters in")
-			.setRequired(false)
-			)
-			.addStringOption( option =>
-				option.setName('messageid')
+				.setDescription("String to count characters in")
+				.setRequired(false)
+		)
+		.addStringOption(option =>
+			option.setName('messageid')
 				.setDescription("Message ID of message to count characters in")
 				.setRequired(false)
-				),
-	async execute(interaction) {
+		),
+	async execute(interaction, client) {
 		var inputString;
-		
+
 		if (interaction.options.getString('string') !== null) {
 			inputString = interaction.options.getString('string');
 		} else if (interaction.options.getString('messageid') !== null) {
@@ -24,9 +24,9 @@ module.exports = {
 			const messagefromId = await client.channels.cache.get(interaction.channel.id).messages.fetch(messageId);
 			inputString = messagefromId.content;
 		}
-		
+
 		await interaction.reply("Input: `" + inputString + "`\n" + "Output: " + codeBlock("", countChars(inputString)));
-        console.log("User " + interaction.user.tag + " ran /count_chars");
+		console.log("User " + interaction.user.tag + " ran /count_chars");
 	},
 };
 
@@ -37,13 +37,13 @@ function countChars(string) {
 	for (let i = 0; i < string.length; ++i) {
 		let currentChar = string.charAt(i);
 		let arrayIndex = currentChar.charCodeAt(0) - 97;
-		if (string.charAt(i).search(/^[a-z]+$/) === 0)  {
+		if (string.charAt(i).search(/^[a-z]+$/) === 0) {
 			letterCount[arrayIndex]++;
 		}
 	}
 	for (let i = 0; i < letterCount.length; ++i) {
 		if (letterCount[i] > 0) {
-				outputString += "Number of " + String.fromCharCode(i + 97).toUpperCase() + "'s: " + letterCount[i] + "\n"; 
+			outputString += "Number of " + String.fromCharCode(i + 97).toUpperCase() + "'s: " + letterCount[i] + "\n";
 		}
 	}
 	return outputString;
diff --git a/commands/listPhrases.ts b/commands/listPhrases.ts
index bbce657..46e2aff 100644
--- a/commands/listPhrases.ts
+++ b/commands/listPhrases.ts
@@ -1,4 +1,4 @@
-const { codeBlock } = require("discord.js"); 
+const { codeBlock } = require("discord.js");
 
 const { SlashCommandBuilder, Discord } = require('discord.js');
 var abbreviationKey = require("../abbreviation_key.json");
@@ -7,8 +7,8 @@ module.exports = {
 	data: new SlashCommandBuilder()
 		.setName('list_phrases')
 		.setDescription('Lists phrases in target phrases.'),
-	async execute(interaction) {
+	async execute(interaction, client) {
 		await interaction.reply("Here are the current phrases in the phrase list:" + codeBlock("json", JSON.stringify(abbreviationKey.target_phrases, null, " ")));
-        console.log("User " + interaction.user.tag + " ran /list_phrases");
+		console.log("User " + interaction.user.tag + " ran /list_phrases");
 	},
 };
diff --git a/commands/ping.ts b/commands/ping.ts
index bbe2edb..ece8a3c 100644
--- a/commands/ping.ts
+++ b/commands/ping.ts
@@ -4,8 +4,8 @@ module.exports = {
 	data: new SlashCommandBuilder()
 		.setName('ping')
 		.setDescription('Replies with Pong!'),
-	async execute(interaction) {
+	async execute(interaction, client) {
 		await interaction.reply('Pong!');
-        console.log("User " + interaction.user.tag + " ran /ping");
+		console.log("User " + interaction.user.tag + " ran /ping");
 	},
 };