urban dictionary: rename the schame from Definitiosn to UrbanDictionary to avoid confusion

This commit is contained in:
Ayden Jahola 2024-09-08 01:28:21 +01:00
parent 80563bcb9f
commit 2c079eb173
No known key found for this signature in database
GPG key ID: 71DD90AE4AE92742
2 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,6 @@
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const axios = require("axios"); const axios = require("axios");
const Definition = require("../../models/UrbanDictionary"); const UrbanDictionary = require("../../models/UrbanDictionary");
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@ -21,7 +21,7 @@ module.exports = {
try { try {
// Check if the term exists in the database // Check if the term exists in the database
let definition = await Definition.findOne({ term }); let definition = await UrbanDictionary.findOne({ term });
if (!definition) { if (!definition) {
// If definition is not found, fetch from the API // If definition is not found, fetch from the API
@ -50,7 +50,7 @@ module.exports = {
} }
// Save the new definition to the database // Save the new definition to the database
definition = new Definition({ definition = new UrbanDictionary({
term, term,
definition: data.list[0].definition, definition: data.list[0].definition,
example: data.list[0].example || "No example provided", example: data.list[0].example || "No example provided",

View file

@ -1,6 +1,6 @@
const mongoose = require("mongoose"); const mongoose = require("mongoose");
const definitionSchema = new mongoose.Schema({ const UrbanDictionarySchema = new mongoose.Schema({
term: { type: String, required: true, unique: true, trim: true }, term: { type: String, required: true, unique: true, trim: true },
definition: { type: String, required: true }, definition: { type: String, required: true },
example: { type: String, default: "No example provided" }, example: { type: String, default: "No example provided" },
@ -9,6 +9,9 @@ const definitionSchema = new mongoose.Schema({
thumbs_down: { type: Number, default: 0 }, thumbs_down: { type: Number, default: 0 },
}); });
const Definition = mongoose.model("Definition", definitionSchema); const UrbanDictionary = mongoose.model(
"UrbanDictionary",
UrbanDictionarySchema
);
module.exports = Definition; module.exports = UrbanDictionary;