added listPhrases

This commit is contained in:
2023-04-01 11:29:41 -05:00
parent f7cc98adab
commit ecf90a7b8b
3 changed files with 19 additions and 10 deletions

View File

@@ -6,22 +6,17 @@ console.log(abbreviationKey);
module.exports = {
data: new SlashCommandBuilder()
.setName("add_phrase")
.setDescription("adds abbreviation to respond to")
.setName("remove_phrase")
.setDescription("removes abbreviation")
.addStringOption( (option) =>
option.setName("abbreviation")
.setDescription("The abbreviation to target")
.setRequired(true)
)
.addStringOption( option =>
option.setName('phrase')
.setDescription("The phrase that the abbreviation shortens")
.setRequired(true)
),
async execute(interaction) {
var abbreviation = interaction.options.getString('abbreviation').toLowerCase();
//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);
},
};
@@ -38,7 +33,7 @@ function removePhrase(abbrevation) {
var jsonPath = path.join(__dirname, '..', 'abbreviation_key.json');
fs.unlinkSync(jsonPath);
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) {
console.error(err);
}