I am working on a command where you type ?send it will then delete your message and send the message through the node.js bot but right now it sends the full message including the command How am I able to make it so that it will remove the prefix and command and just send what follows the command
My Code
module.exports = {
name: `send`,
description: "sends a message through the bot",
execute (client, message, args){
const channel = client.channels.cache.get('id');
const Crash = message.guild.roles.cache.find(r => r.name === "Crash");
if(message.member.roles.cache.has(Crash.id)) {
message.delete({timeout: 100})
message.channel.send(`${message.content}`);
} else {
message.channel.send(`You cant use this command`);
}
}
}
CodePudding user response:
It looks like you're using a command handler that passes the args
of the message command to the 3rd parameter of the execute
function. I'm not sure how your command handler works but I assume args is an array of words in the message, not including the command or prefix. Try using the Array.join()
function to join the args into a single string (with a space in between the words) and send that:
message.channel.send(`${args.join(" ")}`);