mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Owners can bypass cooldowns with non persistent toggle (#4440)
* dev bypas cooldowns * Toggleable within dev, new attrib * Reuqested changes * Remake content * Looks like `reset_cooldown()` is under Command object :) * Remove `await` Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
300346dcd4
commit
d01bca2314
@ -162,6 +162,7 @@ class RedBase(
|
|||||||
self._ignored_cache = IgnoreManager(self._config)
|
self._ignored_cache = IgnoreManager(self._config)
|
||||||
self._whiteblacklist_cache = WhitelistBlacklistManager(self._config)
|
self._whiteblacklist_cache = WhitelistBlacklistManager(self._config)
|
||||||
self._i18n_cache = I18nManager(self._config)
|
self._i18n_cache = I18nManager(self._config)
|
||||||
|
self._bypass_cooldowns = False
|
||||||
|
|
||||||
async def prefix_manager(bot, message) -> List[str]:
|
async def prefix_manager(bot, message) -> List[str]:
|
||||||
prefixes = await self._prefix_cache.get_prefixes(message.guild)
|
prefixes = await self._prefix_cache.get_prefixes(message.guild)
|
||||||
|
|||||||
@ -369,3 +369,18 @@ class Dev(commands.Cog):
|
|||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
ctx.message.author = old_author
|
ctx.message.author = old_author
|
||||||
ctx.message.content = old_content
|
ctx.message.content = old_content
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@checks.is_owner()
|
||||||
|
async def bypasscooldowns(self, ctx, toggle: Optional[bool] = None):
|
||||||
|
"""Give bot owners the ability to bypass cooldowns.
|
||||||
|
|
||||||
|
Does not persist through restarts."""
|
||||||
|
if toggle is None:
|
||||||
|
toggle = not ctx.bot._bypass_cooldowns
|
||||||
|
ctx.bot._bypass_cooldowns = toggle
|
||||||
|
|
||||||
|
if toggle:
|
||||||
|
await ctx.send(_("Bot owners will now bypass all commands with cooldowns."))
|
||||||
|
else:
|
||||||
|
await ctx.send(_("Bot owners will no longer bypass all commands with cooldowns."))
|
||||||
|
|||||||
@ -292,6 +292,11 @@ def init_events(bot, cli_flags):
|
|||||||
elif isinstance(error, commands.CheckFailure):
|
elif isinstance(error, commands.CheckFailure):
|
||||||
pass
|
pass
|
||||||
elif isinstance(error, commands.CommandOnCooldown):
|
elif isinstance(error, commands.CommandOnCooldown):
|
||||||
|
if bot._bypass_cooldowns and ctx.author.id in bot.owner_ids:
|
||||||
|
ctx.command.reset_cooldown(ctx)
|
||||||
|
new_ctx = await bot.get_context(ctx.message)
|
||||||
|
await bot.invoke(new_ctx)
|
||||||
|
return
|
||||||
if delay := humanize_timedelta(seconds=error.retry_after):
|
if delay := humanize_timedelta(seconds=error.retry_after):
|
||||||
msg = _("This command is on cooldown. Try again in {delay}.").format(delay=delay)
|
msg = _("This command is on cooldown. Try again in {delay}.").format(delay=delay)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user