1
votes

I was curious if anyone could help me out here.

My bot has a suggestions channel, for the players to provide suggestions to make the server better.
However, it gets clustered because they chat. I was curious if there was a way to delete any message in the specific channel, except bot commands?

Thanks!

1

1 Answers

1
votes

Well, you can check if the message starts with your prefix or has been sent by a bot: if none of those, it means it's not a command nor a command response. All of that assuming the message is in that channel.

// ASSUMPTIONS:
// channel = your channel as a TextChannel
// prefix = your prefix as a string
// owner = you as a User

client.on('message', msg => {
  if (msg.channel != channel || msg.author.bot || msg.content.startsWith(prefix)) return;
  else msg.delete();
});

// if you want your messages to be ignored too:
client.on('message', msg => {
  if (msg.channel != channel || msg.author.bot || msg.content.startsWith(prefix) || msg.author == owner) return;
  else msg.delete();
});