added listPhrases

master
Chloe Fontenot 🏳️‍⚧️ 2023-04-01 11:29:41 +07:00
parent f7cc98adab
commit ecf90a7b8b
3 changed files with 19 additions and 10 deletions

@ -1 +1 @@
{"target_phrases":{"idk":"I don't know","hoco":"homecoming","bbl":"be back later","bbg":"baby girl","mb":"my bad","mfw":"my face when","tfw":"that face when","ebr":"East Baton Rouge","ttyl":"talk to you later","ab":"about","w":"with","abt":"about","dk":"don't know","prolly":"probably","tbh":"to be honest","smh":"shaking my head","btw":"by the way","ngl":"not gonna lie","fr":"for real","yessss":"yes","bc":"because","u":"you","thru":"through","lmao":"laughing my ass off","tldr":"too long; didn't read","tl;dr":"too long; didn't read","ofc":"of course","linux":"GNU/Linux","xfl":"Extreme Football League","bi":"bisexual","abbr":"abbreviation","jk":"just kidding","gm":"good morning","mc":"Minecraft"}} {"target_phrases":{"idk":"I don't know","hoco":"homecoming","bbl":"be back later","bbg":"baby girl","mb":"my bad","mfw":"my face when","tfw":"that face when","ebr":"East Baton Rouge","ttyl":"talk to you later","ab":"about","abt":"about","dk":"don't know","prolly":"probably","tbh":"to be honest","smh":"shaking my head","btw":"by the way","ngl":"not gonna lie","fr":"for real","yessss":"yes","bc":"because","u":"you","thru":"through","lmao":"laughing my ass off","tldr":"too long; didn't read","ofc":"of course","linux":"GNU/Linux","xfl":"Extreme Football League","bi":"bisexual","abbr":"abbreviation","jk":"just kidding","gm":"good morning","mc":"Minecraft","nfl":"National Football League","ygd":"you're gonna die","gn":"goodnight"}}

@ -0,0 +1,14 @@
const { codeBlock } = require("discord.js");
const { SlashCommandBuilder, Discord } = require('discord.js');
var abbreviationKey = require("../abbreviation_key.json");
module.exports = {
data: new SlashCommandBuilder()
.setName('list_phrases')
.setDescription('Lists phrases in target phrases.'),
async execute(interaction) {
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");
},
};

@ -6,22 +6,17 @@ console.log(abbreviationKey);
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("add_phrase") .setName("remove_phrase")
.setDescription("adds abbreviation to respond to") .setDescription("removes abbreviation")
.addStringOption( (option) => .addStringOption( (option) =>
option.setName("abbreviation") option.setName("abbreviation")
.setDescription("The abbreviation to target") .setDescription("The abbreviation to target")
.setRequired(true) .setRequired(true)
)
.addStringOption( option =>
option.setName('phrase')
.setDescription("The phrase that the abbreviation shortens")
.setRequired(true)
), ),
async execute(interaction) { async execute(interaction) {
var abbreviation = interaction.options.getString('abbreviation').toLowerCase(); var abbreviation = interaction.options.getString('abbreviation').toLowerCase();
//var phrase = interaction.options.getString('phrase'); //var phrase = interaction.options.getString('phrase');
await interaction.reply('Removing abbreviation `' + abbreviation + "` from the target list... `"); await interaction.reply('Removing abbreviation `' + abbreviation + "` from the target list...");
removePhrase(abbreviation); removePhrase(abbreviation);
}, },
}; };
@ -38,7 +33,7 @@ function removePhrase(abbrevation) {
var jsonPath = path.join(__dirname, '..', 'abbreviation_key.json'); var jsonPath = path.join(__dirname, '..', 'abbreviation_key.json');
fs.unlinkSync(jsonPath); fs.unlinkSync(jsonPath);
fs.writeFileSync(jsonPath, jsonString, { encoding: 'utf8' }, "\t"); fs.writeFileSync(jsonPath, jsonString, { encoding: 'utf8' }, "\t");
console.log("Removed abbreviation from list. JSON now contains:" + abbreviationKey); console.log("Removed abbreviation from list. JSON now contains:" + abbreviationKey.target_phrases);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }