whenever I run this command the bot doesn't respond - no errors. I have the role that matched in r.id?
client.on('message', async message => {
// Check if the user has a role with an id
if(message.author.bot) return;
if(!message.member.roles.cache.some(r => r.id === '1007043154182160466')){
if (message.content === '.say') {
const SayMessage = message.content.slice(4).trim();
setTimeout(function(){
message.delete()
}, `50`)
message.channel.send(SayMessage)
client.channels.cache.get('100704202s2756065411').send(SayMessage " " "**from**" " " "**" (message.author.username) "**" " " "(" (message.author) ")")
} else {
return message.react('⛔');
}
}
}
);
CodePudding user response:
Looks like you have a problem where you check the message.content
. From your line with message.content.slice(4).trim()
I assume the command you are creating requires more arguments, like ".say hello world" or something along those lines. So when you use if (message.content === ".say")
, that checks if the content has nothing except ".say". There are a lot of ways to fix this, but for now you should just check if the content starts with .say, using the string.startsWith() function:
if (message.content.startsWith(".say")) {
const SayMessage = message.content.slice(4).trim();
// all the rest of your code here
}