In my discord bot , I want all users to have a customizable profile. Whenever they run a command !profile or !p , the bot will display an embed with bio (which is like an introduction like "Hello World" or something) , custom embed color of their choice and other database information (.ie coins, energy etc.) . I want to make sure that whenever they run something like !desc Hello World , their profile embed will have the message Hello World, and if they run !desc Lorem another time, their custom embed's bio will be edited to Lorem and so on. I got them implement with simple db.get and db.set function using quick.db but the problem is whenever the user sets a description with more than one arguments like Hello World , it only appears on the embed as HelloWorld but not the actual correct one with spaces. I really want the embed to display exactly what the user sets its description (with spaces and stuffs ) but currently my code isn't capable of it. Please give it a look and point out where I should change!
const db = require("quick.db");
const Discord = require("discord.js");
module.exports = {
commands: ["description", "desc"],
minArgs: 1,
maxArgs: null,
expectedArgs: ["description to add"],
callback: (message, arguments, text) => {
var desc;
desc = arguments.join("");
let tester = db.get(`_desc${message.author.id}`);
if (!tester) {
db.set(`_desc${message.author.id}`, desc);
} else {
db.delete(`_desc${message.author.id}`), db.set(`_desc${message.author.id}`, desc);
}
console.log(desc);
},
};
The above is the code for !desc and the below is the one for !profile.
const db = require("quick.db");
const Discord = require("discord.js");
module.exports = {
commands: ["profile", "p"],
alias: ["p"],
minArgs: 0,
maxArgs: null,
callback: async (message, arguments, text) => {
let target = message.mentions.members.first() || message.author;
const balance = db.get(`honey_${target.id}`);
const energy = db.get(`energy_${target.id}`);
var desc = db.get(`_desc${target.id}`);
if (desc === null) {
let desc = "this user have yet to set a description!";
}
const embed = new Discord.MessageEmbed()
.setTitle(`${target.tag}'s profile`)
.setColor("#ECB802")
.addFields(
{ name: "Description", value: `${desc}`, inline: false },
{
name: "cards",
value: "1",
inline: true,
//to do
},
{ name: "Gym battle record", value: "1/0", inline: true }, //to do
{
name: "Honey",
value: `${balance} :honey_pot:`,
inline: true,
},
{
name: "energy",
value: `${energy} :dizzy:`,
inline: true,
},
);
message.channel.send(embed);
},
};
You're using
arguments.join('')
to get the description, which will join two strings with an empty string: