mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
* Move ignored guilds and channels to core Add caching for ignored guilds and channels Add caching for whitelist and blacklist Fix #3220 Add consume-rest for whitelist and blacklist commands to add multiple users or roles in one command * Add ability to ignore channel categories * black * moveignorechannels should be owner only and cleanup changes * add changelog entries * address Feedback
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
import logging
|
|
import asyncio
|
|
import contextlib
|
|
|
|
import discord
|
|
from redbot.core import commands, checks, i18n
|
|
from redbot.core.utils.chat_formatting import box
|
|
from .abc import MixinMeta
|
|
|
|
log = logging.getLogger("red.mod")
|
|
_ = i18n.Translator("Mod", __file__)
|
|
|
|
|
|
# TODO: Empty this to core red.
|
|
class MoveToCore(MixinMeta):
|
|
"""
|
|
Mixin for things which should really not be in mod, but have not been moved out yet.
|
|
"""
|
|
|
|
@commands.Cog.listener()
|
|
async def on_command_completion(self, ctx: commands.Context):
|
|
await self._delete_delay(ctx)
|
|
|
|
@commands.Cog.listener()
|
|
async def on_command_error(self, ctx: commands.Context, error: Exception):
|
|
# Every message which isn't a command but which
|
|
# starts with a bot prefix is dispatched as a command error
|
|
if not isinstance(error, commands.CommandNotFound):
|
|
await self._delete_delay(ctx)
|
|
|
|
async def _delete_delay(self, ctx: commands.Context):
|
|
"""Currently used for:
|
|
* delete delay"""
|
|
guild = ctx.guild
|
|
if guild is None:
|
|
return
|
|
message = ctx.message
|
|
delay = await self.settings.guild(guild).delete_delay()
|
|
|
|
if delay == -1:
|
|
return
|
|
|
|
async def _delete_helper(m):
|
|
with contextlib.suppress(discord.HTTPException):
|
|
await m.delete()
|
|
log.debug("Deleted command msg {}".format(m.id))
|
|
|
|
await asyncio.sleep(delay)
|
|
await _delete_helper(message)
|