I want to store a word that was provided as an arg after a command from a user in a quick.db database. I'm pretty new to quick.db and it's my first time using it. Can someone help? Thank you sm!
I'm unsure how your commands are formatted, if the following doesn't work, please comment!
const db = require('quick.db');
const user = message.mentions.users.first();
if(!user) return message.channel.send('You must mention a message!');
const message = args.splice(1).join(` `);
if(!message) return message.channel.send(`You must provide a message`);
db.set('message' + user.id, message);
message.channel.send(`Successfully set the ${user.tag}\'s message as: ${message}`)
The first db requirement defines db, the user is the first mentioned user inside of a message.
const message = args.splice(1).join(` `);
if(!message) return message.channel.send(`You must provide a message`);
The const message
defines the message you are receiving, it splices the user and joins the string with spaces. It prevents errors by checking if the message exists, if it doesn't it returns.
db.set('message' + user.id, message);
message.channel.send(`Successfully set the ${user.tag}\'s message as: ${message}`)
This part just sets the message into the database.