Add countChars function

This commit is contained in:
2023-04-04 17:15:56 -05:00
parent 2568a72651
commit 8e60943ba7
2 changed files with 19 additions and 3 deletions

View File

@@ -7,10 +7,24 @@ module.exports = {
.addStringOption( option =>
option.setName('string')
.setDescription("String to count characters in")
.setRequired(true)
),
.setRequired(false)
)
.addStringOption( option =>
option.setName('messageid')
.setDescription("Message ID of message to count characters in")
.setRequired(false)
),
async execute(interaction) {
var inputString = interaction.options.getString('string');
var inputString;
if (interaction.options.getString('string') !== null) {
inputString = interaction.options.getString('string');
} else if (interaction.options.getString('messageid') !== null) {
var messageId = interaction.options.getString('messageid');
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");
},