Finding results with mongodb

I have a db full of skills and I’m trying to make an info cmd where if you type the skill name you will get some info on it. Some skills are 2-3 arguments. For example "Animal Call". I want to be able to find my skill in mongodb by typing both !info animal call and for example something short like !info ani call

The problem about this is that if i try to find it with !info ani call it wont show up as a result.

Here’s my code:

let skill = args.slice(0).join(" ");

const skillDB = await Skill.find({})

for (let i = 0; i < skillDB.length; i++) {
 if (skillDB[i].skillName.toLowerCase().includes(`${skill.toLowerCase()}`)) {
  const embed = new MessageEmbed()
  .setDescription(`\`${skillDB[i].skillIcon}\` ${skillDB[i].skillName}`)

9 thoughts on “Finding results with mongodb”

Leave a Comment