remove not needed fields and clean up a bit

This commit is contained in:
Ayden Jahola 2024-09-14 21:55:33 +01:00
parent 7616d82a8b
commit 037c4ea63b
No known key found for this signature in database
GPG key ID: 71DD90AE4AE92742
2 changed files with 9 additions and 14 deletions

View file

@ -29,13 +29,13 @@ module.exports = {
async execute(interaction) { async execute(interaction) {
const word = interaction.options.getString("word").toLowerCase(); const word = interaction.options.getString("word").toLowerCase();
const isEphemeral = interaction.options.getBoolean("ephemeral") || false; const isEphemeral = interaction.options.getBoolean("ephemeral") || false;
const wordnikUrl = `https://www.wordnik.com/words/${word}`; const defaultWordnikUrl = `https://www.wordnik.com/words/${word}`;
// Create the base embed // Create the base embed
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setColor("#0099ff") .setColor("#0099ff")
.setTitle(`Dictionary: ${word.charAt(0).toUpperCase() + word.slice(1)}`) .setTitle(`Dictionary: ${word.charAt(0).toUpperCase() + word.slice(1)}`)
.setURL(wordnikUrl) // Set URL to the Wordnik page for the word .setURL(defaultWordnikUrl) // Set URL to the Wordnik page for the word
.setFooter({ .setFooter({
text: "Powered by Wordnik | Source: Loading...", text: "Powered by Wordnik | Source: Loading...",
iconURL: "https://wordnik.com/favicon.ico", iconURL: "https://wordnik.com/favicon.ico",
@ -56,11 +56,9 @@ module.exports = {
`**Source Dictionary:** ${ `**Source Dictionary:** ${
result.sourceDictionary || "Unknown source" result.sourceDictionary || "Unknown source"
}\n` + }\n` +
`**Synonyms:** ${result.synonyms.join(", ") || "None found"}\n` +
`**Antonyms:** ${result.antonyms.join(", ") || "None found"}\n` +
`**Example:** ${result.exampleSentence || "No examples found"}` `**Example:** ${result.exampleSentence || "No examples found"}`
) )
.setURL(result.wordnikUrl || wordnikUrl) .setURL(result.wordnikUrl || defaultWordnikUrl) // Use URL from database or default
.setFooter({ .setFooter({
text: `Powered by Wordnik | Source: Database`, text: `Powered by Wordnik | Source: Database`,
iconURL: "https://wordnik.com/favicon.ico", iconURL: "https://wordnik.com/favicon.ico",
@ -93,7 +91,7 @@ module.exports = {
definitionData.attributionText || "No attribution"; definitionData.attributionText || "No attribution";
const sourceDictionary = const sourceDictionary =
definitionData.sourceDictionary || "Unknown source"; definitionData.sourceDictionary || "Unknown source";
const wordnikUrl = definitionData.wordnikUrl || wordnikUrl; const wordnikUrl = definitionData.wordnikUrl || defaultWordnikUrl; // Use local URL or default
// Example sentence extraction (make sure `exampleUses` is correctly handled) // Example sentence extraction (make sure `exampleUses` is correctly handled)
const exampleSentence = const exampleSentence =
@ -121,9 +119,8 @@ module.exports = {
`**Source Dictionary:** ${sourceDictionary}\n` + `**Source Dictionary:** ${sourceDictionary}\n` +
`**Example:** ${exampleSentence}` `**Example:** ${exampleSentence}`
) )
.setURL(wordnikUrl); // Add a URL to the embed if available .setURL(wordnikUrl) // Use URL from API response
.setFooter({
embed.setFooter({
text: `Powered by Wordnik | Source: API`, text: `Powered by Wordnik | Source: API`,
iconURL: "https://wordnik.com/favicon.ico", iconURL: "https://wordnik.com/favicon.ico",
}); });

View file

@ -6,8 +6,6 @@ const wordSchema = new mongoose.Schema({
partOfSpeech: { type: String, default: "Unknown" }, partOfSpeech: { type: String, default: "Unknown" },
attributionText: { type: String, default: "No attribution" }, attributionText: { type: String, default: "No attribution" },
sourceDictionary: { type: String, default: "Unknown source" }, sourceDictionary: { type: String, default: "Unknown source" },
synonyms: { type: [String], default: [] },
antonyms: { type: [String], default: [] },
exampleSentence: { type: String, default: "No examples found" }, exampleSentence: { type: String, default: "No examples found" },
wordnikUrl: { type: String, default: "" }, wordnikUrl: { type: String, default: "" },
attributionUrl: { type: String, default: "" }, attributionUrl: { type: String, default: "" },