Merge branch 'master' of ssh://gitea.calebfontenot.com:25566/CCF_100/NoMoreAcronyms
This commit is contained in:
commit
2e62646bd9
@ -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 + "`");
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
},
|
||||
};
|
||||
|
@ -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");
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user