For a Discord server, I have a bot that whenever the frequency of messages from members is too great, the bot enables slowmode. The problem is that I do not know how to tackle the problem (i.e. how do you detect the number of messages in any time span?). I just need to divide numberOfMessages by timePeriod (timePeriod will reset itself every 10 seconds so that we take the average messages per 10 seconds.)
How do I get the number of messages that were sent in the last 10 seconds?