Reputation: 3
I want to have a command which is similar to "say" command but it's only restricted to bot owner and only sent in one channel at a specific server. Any tips?
Here's my code (not working atm):
client.on("message", (message) => {
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command === "+ubersay") {
if(message.author.id !== process.env.ownerID) return;
const sayMessage = args.join(" ");
message.delete().catch(O_o=>{});
client.channels.get(process.env.specifiedChannel).send(sayMessage);
}
});
Upvotes: 0
Views: 244
Reputation: 2785
The code should work flawlessly, the only thing that could be a problem is your const args = message.content.slice(prefix.length).trim().split(/ +/g);
combined with if(command === "+ubersay") {
Because this askes for your Command to be used in the format [prefix]+ubersay
so if your prefix is + you would need to do ++ubersay
Upvotes: 1