mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Prevent LicenseInfo command from being a source of user command spam (#4110)
* Prevent LicenseInfo command from being a source of user command spam * add dep-warn explaining whats needed for this * name issues * Tests... * An empty commit unbroke some of it, but still style issues
This commit is contained in:
parent
832bdfde22
commit
d73ad3115f
@ -2749,6 +2749,21 @@ class Core(commands.Cog, CoreLogic):
|
||||
return msg
|
||||
|
||||
|
||||
# DEP-WARN: CooldownMapping should have a method `from_cooldown`
|
||||
# which accepts (number, number, bucket)
|
||||
# the bucket should only be used for the method `_bucket_key`
|
||||
# and `_bucket_key` should be used to determine the grouping
|
||||
# of ratelimit consumption.
|
||||
class LicenseCooldownMapping(commands.CooldownMapping):
|
||||
"""
|
||||
This is so that a single user can't spam a channel with this
|
||||
it's used below as 1 per 3 minutes per user-channel combination.
|
||||
"""
|
||||
|
||||
def _bucket_key(self, msg):
|
||||
return (msg.channel.id, msg.author.id)
|
||||
|
||||
|
||||
# Removing this command from forks is a violation of the GPLv3 under which it is licensed.
|
||||
# Otherwise interfering with the ability for this command to be accessible is also a violation.
|
||||
@commands.command(
|
||||
@ -2770,3 +2785,9 @@ async def license_info_command(ctx):
|
||||
)
|
||||
await ctx.send(message)
|
||||
# We need a link which contains a thank you to other projects which we use at some point.
|
||||
|
||||
|
||||
# DEP-WARN: command objects should store a single cooldown mapping as `._buckets`
|
||||
license_info_command._buckets = LicenseCooldownMapping.from_cooldown(
|
||||
1, 180, commands.BucketType.member # pick a random bucket,it wont get used.
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user