aternosorg / modbot

An open source moderation bot with advanced features developed by Aternos.
MIT License
127 stars 61 forks source link

Add a cooldown for tags (auto-responses) per-channel cooldowns #589

Closed TyladYT closed 9 months ago

TyladYT commented 12 months ago

This modification adds a cooldown per auto-response (tags) per-channel to make sure that if multiple people execute a tag all at once, then the bot doesn't send it twice. It'll only respond to one tag. E.G. If a user asks, "how do I appeal?", then four people execute !appeal to show the user what to do, that message is sent 4 times. But with this modification, the bot only replies to one, and reacts with the timer emoji for the rest.

CLAassistant commented 12 months ago

CLA assistant check
All committers have signed the CLA.

Soapy7261 commented 12 months ago

Wouldn't this be better to be an option a server owner can set instead of being hard coded (and being forced on)?

JulianVennen commented 12 months ago

This sounds like a nice thing to add but there are a few small issues with this implementation:

  1. I think the timeout should apply per channel AND per auto response. This could be achieved by using channelId + ":" + autoResponseId as the key for the set
  2. I don't think reacting to the message is necessary if the response is under cooldown.
  3. I think most of the comments you added are redundant since they more or less just repeat the code before it.
Soapy7261 commented 12 months ago

I think the timeout should apply per channel AND per auto response. This could be achieved by using channelId + ":" + autoResponseId as the key for the set

I kind of disagree, because if you have multiple tickets and such with different staff members handling different tickets, or just overall a lot of tickets, this could be annoying (forced, at least)

JulianVennen commented 12 months ago

The point was that you can use different auto responses at the same time or the same auto response in different channels at the same time.

Look at the implementation example

TyladYT commented 12 months ago
  1. I think the timeout should apply per channel AND per auto response. This could be achieved by using channelId + ":" + autoResponseId as the key for the set

I completely agree with how it should be based per-channel AND per-autoresponse, this would enforce cooldowns a lot better since then people won't have to wait the cooldown out if another user has used the same tag/autoresponse in the other channel. I will implement this suggestion into my ModBot instance, and continue testing.

  1. I don't think reacting to the message is necessary if the response is under cooldown.

I think a reaction is necessary, due to letting the user know that a cooldown is currently active. It would make things much easier and simple to apply to the user's mind, letting them know "Hey, a cooldown is currently in place" without actually sending a message, because atm in my opinion ModBot is just messages everywhere right now. Adding a reaction would ease things up a bit in this aspect, if you get what I mean? At one time, Minehut used a cooldown emoji for their bot, the same timer one I used in this code snippet. It worked as a fantastic solution rather than replying to the message and then deleting the reply. Plus, you can't reply to messages in ephemeral responses meaning it would be pretty pointless to reply with a cooldown message if it's not ephemeral. Nobody needs to see a "This command is on cooldown" message or whatever, a reaction fits just perfectly.

Feel free to ask me questions, I can elaborate at any time if you like.

JulianVennen commented 12 months ago

Autoresponses are not always commands and if the bot reacts to your message with an emoji, and you don't know that it would usually have responded to that message, that might be confusing.

I think it would generally be a good thing to implement a real "tag" system that uses slash commands for your use case. This could use an ephemeral response when the tag is on "timeout" while also removing the message before it, providing autocompletion etc.