I am wondering if there is a way to save a variable from a command like this:
!name nameOfPerson
!age ageOfPerson
and then save it to a database?
What would be a better way to handle this? maybe an array?
I am wondering if there is a way to save a variable from a command like this:
!name nameOfPerson
!age ageOfPerson
and then save it to a database?
What would be a better way to handle this? maybe an array?
You might want to try listening on the message
event.
https://discord.js.org/#/docs/main/stable/class/Message
You can split each message into an array of words, and then add logic for each of your commands based on the first index.
const client = new Discord.Client()
client.on('message', message => {
let msg = message.content.split(' ') // Split on space
if (msg[0] === '!age') database_save_logic(message.author, msg[1])
if (msg[0] === '!name') database_save_logic(message.author, msg[1])
})