Story:
I've only recently started java script and discord.js after my friend joked about having his own discord bot so I made a basic one as a gimmick, but apparently its turned serious and I really like coding the bot so I continued. I've been trying to make a command that makes the bot embed a title and description (ex. !embed (Title here) | (Description here)) so anyone who has the right permissions can use the bot to embed but i'm either really dumb or extremely persistent on a so called lead in my code that leads to nowhere.
Problem:
cannot seem to get the title input and the desc. input to not mess with each other in a weird way (Putting the title into the desc or the other way around) the vertical slash is suppose to be the divider between the title and desc. but i can't get it to work no-matter how hard I mess with my code.
Code:
const Discord = require("discord.js");
module.exports.run = async (client, msg, args) => {
args.slice(0).join(" ")
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(args[0])
.setDescription(args.slice(1).join(" "))
msg.channel.send(embed);
}
module.exports.help = {
name: "embed"
}
The error is just here args.slice(0).join(" ")
.
You need to store the new value of the args into the args value to update it.
So change that to: args = args.slice(0).join(" ")
And normally it will perfectly work!
Edit:
You can use a specific typo in the command like -command -t Title with multiple words -d Description with multiple words
.
Then you can adapt your code.
const Discord = require("discord.js");
module.exports.run = async (client, msg, args) => {
args.slice(0).join(" ")
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(args.join(" ").split("-t")[1].split("-d")[0].trim())
.setDescription(args.join(" ").split("-d")[1].trim())
msg.channel.send(embed);
}
module.exports.help = {
name: "embed"
}