Refactor Translator Cog to enhance user experience with improved error handling and message formatting options. Introduce new features for better command usability and update command descriptions for clarity.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run

This commit is contained in:
Valerie 2025-05-24 03:12:39 -04:00
parent 576604b727
commit 32401f31d8
2 changed files with 53 additions and 0 deletions

33
silentmode/__init__.py Normal file
View file

@ -0,0 +1,33 @@
from redbot.core import commands
from discord.ext.commands import Cog
from redbot.core.bot import Red
import discord
class SilentMode(commands.Cog):
"""Makes the bot use @silent for every message it sends."""
def __init__(self, bot: Red):
self.bot = bot
self.original_send = discord.abc.Messageable.send
discord.abc.Messageable.send = self._silent_send
def cog_unload(self):
"""Restore the original send method when the cog is unloaded."""
discord.abc.Messageable.send = self.original_send
async def _silent_send(self, *args, **kwargs):
"""Override the send method to add @silent to every message."""
if args and isinstance(args[0], str):
args = ("@silent " + args[0],) + args[1:]
elif "content" in kwargs and kwargs["content"]:
kwargs["content"] = "@silent " + kwargs["content"]
elif not kwargs.get("content") and (kwargs.get("embed") or kwargs.get("file")):
kwargs["content"] = "@silent"
return await self.original_send(self, *args, **kwargs)
async def setup(bot: Red):
"""Add the cog to the bot."""
await bot.add_cog(SilentMode(bot))

20
silentmode/info.json Normal file
View file

@ -0,0 +1,20 @@
{
"name": "SilentMode",
"short": "Makes the bot use @silent for every message it sends",
"description": "A cog that automatically adds @silent to every message the bot sends, reducing notifications in servers.",
"end_user_data_statement": "This cog does not store any user data.",
"author": [
"Valerie"
],
"required_cogs": {},
"requirements": [],
"tags": [
"utility",
"silent",
"notifications"
],
"min_bot_version": "3.5.0",
"hidden": false,
"disabled": false,
"type": "COG"
}