I'm wanting to be able to embed specific DnD spells taken from the 5e Api using a Discord bot. I can log all of the spells to the console using node-fetch but completely unsure of the next step in grabbing user input, mapping it to the correct spell and then embeding it.
What the console log looks like after running the command:
{
count: 319,
results: [
{
index: 'acid-arrow',
name: 'Acid Arrow',
url: '/api/spells/acid-arrow'
},
(*Continuing on for all of the spells*)
I essentially would like the command to be:
!s acid arrow (for example)
Which then returns:
Here is the code from the command I have so far:
const fetch = require('node-fetch');
const Discord = require('discord.js');
module.exports = {
name: 'spells',
aliases: ['s'],
category: 'dnd',
description: 'Returns spell info',
usage: '!s <spell name>',
run: async (client, message, args) => {
fetch('https://www.dnd5eapi.co/api/spells/')
.then(res => res.json())
.then(json => console.log(json));
**?????????????;**
const embed = new Discord.MessageEmbed()
.setTitle()
.addField('Description:')
.addField('At higher levels:')
.addField('Range:')
.addField('Components:')
.addField('Materials needed:')
.addField('Is it a ritual:')
.addField('Needs concentration:')
.addField('Level:')
.addField('Casting time:');
message.channel.send({ embed });
},
};