Skip to content

Commit

Permalink
[All] Minor code improvements (Config variables & blank __init__).
Browse files Browse the repository at this point in the history
  • Loading branch information
AAA3A-AAA3A committed May 12, 2024
1 parent 27d51ab commit b9fa9a4
Show file tree
Hide file tree
Showing 50 changed files with 207 additions and 636 deletions.
11 changes: 0 additions & 11 deletions acronymgame/acronymgame.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
class AcronymGame(Cog):
"""A cog to play a random match of Acrononym game, with Modals!"""

def __init__(self, bot: Red) -> None:
super().__init__(bot=bot)

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}

@property
def games(self) -> typing.Dict[discord.Message, AcronymGameView]:
return self.views
Expand Down
24 changes: 11 additions & 13 deletions antinuke/antinuke.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ def __init__(self, bot: Red) -> None:
identifier=205192943327321000143939875896557571750, # 947269490247
force_registration=True,
)
self.antinuke_guild: typing.Dict[str, typing.Union[bool, int]] = {
"logschannel": None, # The channel for logs.
"enabled": False, # Enable the possibility.
"user_dm": True, # Enable the user dm.
"number_detected_member": 1, # Number.
"number_detected_bot": 1, # Number.
}
self.antinuke_member: typing.Dict[str, typing.Union[int, typing.List[int]]] = {
"count": 0, # The count of channel's deletes.
"old_roles": [], # The roles to be handed in if it wasn't a nuke.
}
self.config.register_guild(**self.antinuke_guild)
self.config.register_member(**self.antinuke_member)
self.config.register_guild(
logschannel=None,
enabled=False,
user_dm=True,
number_detected_member=1,
number_detected_bot=1,
)
self.config.register_member(
count=0,
old_roles=[],
)

_settings: typing.Dict[
str, typing.Dict[str, typing.Union[typing.List[str], bool, str]]
Expand Down
8 changes: 0 additions & 8 deletions autotraceback/autotraceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ def __init__(self, bot: Red) -> None:

self.tracebacks: typing.List[str] = []

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}

@commands.is_owner()
@commands.hybrid_command()
async def traceback(
Expand Down
17 changes: 4 additions & 13 deletions calculator/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ def __init__(self, bot: Red) -> None:
identifier=205192943327321000143939875896557571750, # 905683670375
force_registration=True,
)
self.calculator_global: typing.Dict[str, typing.Dict[str, typing.Union[int, str]]] = {
"settings": {
self.config.register_global(
settings={
"time_max": 180,
"color": 0x01D758,
"thumbnail": "https://cdn.pixabay.com/photo/2017/07/06/17/13/calculator-2478633_960_720.png",
},
}
self.config.register_global(**self.calculator_global)
}
)

# blocks: typing.List[block.Block] = [
# block.MathBlock(),
Expand All @@ -68,14 +67,6 @@ def __init__(self, bot: Red) -> None:

self.cache: typing.List[discord.Message] = []

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}

async def calculate(self, expression: str) -> str:
lst = list(expression)
try:
Expand Down
21 changes: 6 additions & 15 deletions clearchannel/clearchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ def __init__(self, bot: Red) -> None:
identifier=205192943327321000143939875896557571750, # 837018163805
force_registration=True,
)
self.clearchannel_guild = {
"channel_delete": True,
"first_message": True,
"author_dm": False,
"custom_message": {},
}
self.config.register_guild(**self.clearchannel_guild)
self.config.register_guild(
channel_delete=True,
first_message=True,
author_dm=False,
custom_message={},
)

_settings: typing.Dict[
str, typing.Dict[str, typing.Union[typing.List[str], bool, str]]
Expand Down Expand Up @@ -74,14 +73,6 @@ async def cog_load(self) -> None:
await super().cog_load()
await self.settings.add_commands()

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}

@commands.guild_only()
@commands.guildowner()
@commands.bot_has_permissions(manage_channels=True)
Expand Down
25 changes: 7 additions & 18 deletions cmdchannel/cmdchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,13 @@ def __init__(self, bot: Red) -> None:
# identifier=205192943327321000143939875896557571750, # 793502759720
# force_registration=True,
# )
# self.cmd_guild: typing.Dict[
# str, typing.Union[typing.Optional[discord.TextChannel], bool]
# ] = {
# "logschannel": None, # The channel for logs.
# "enabled_cmdchannel": True, # Enable the possibility of commands.
# "confirmation_cmdchannel": False, # Enable the confirmation.
# "deletemessage_cmdchannel": False, # Enable the message delete.
# "informationmessage_cmdchannel": False, # Enable the information message.
# }
# self.config.register_guild(**self.cmd_guild)

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}
# self.config.register_guild(
# logschannel=None,
# enabled=True,
# confirmation=False,
# delete_message=False,
# information_message=False,
# )

@commands.Cog.listener()
async def on_message_without_command(self, message: discord.Message) -> None:
Expand Down
15 changes: 3 additions & 12 deletions codesnippets/codesnippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ def __init__(self, bot: Red) -> None:
identifier=205192943327321000143939875896557571750,
force_registration=True,
)
self.codesnippets_guild: typing.Dict[str, typing.List] = {
"channels": [],
}
self.config.register_guild(**self.codesnippets_guild)
self.config.register_guild(
channels=[],
)

self.pattern_handlers = {
GITHUB_RE: self.fetch_github_snippet,
Expand Down Expand Up @@ -125,14 +124,6 @@ async def cog_unload(self) -> None:
await self._session.close()
await super().cog_unload()

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}

async def _fetch_response(self, url: str, response_format: str, **kwargs) -> typing.Any:
if "github.com" in url:
api_tokens = await self.bot.get_shared_api_tokens(service_name="github")
Expand Down
20 changes: 2 additions & 18 deletions commandsbuttons/commandsbuttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,8 @@ def __init__(self, bot: Red) -> None:
force_registration=True,
)
self.CONFIG_SCHEMA: int = 2
self.commands_buttons_global: typing.Dict[str, typing.Optional[int]] = {
"CONFIG_SCHEMA": None,
}
self.commands_buttons_guild: typing.Dict[
str, typing.Dict[str, typing.Dict[str, typing.Dict[str, str]]]
] = {
"commands_buttons": {},
}
self.config.register_global(**self.commands_buttons_global)
self.config.register_guild(**self.commands_buttons_guild)
self.config.register_global(CONFIG_SCHEMA=None)
self.config.register_guild(commands_buttons={})

self.cache: typing.List[commands.Context] = []

Expand All @@ -65,14 +57,6 @@ async def cog_load(self) -> None:
await self.edit_config_schema()
asyncio.create_task(self.load_buttons())

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}

async def edit_config_schema(self) -> None:
CONFIG_SCHEMA = await self.config.CONFIG_SCHEMA()
if CONFIG_SCHEMA is None:
Expand Down
32 changes: 12 additions & 20 deletions consolelogs/consolelogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,26 @@ def __str__(self, with_ansi: bool = False, with_extra_break_line: bool = True) -
class ConsoleLogs(Cog, DashboardIntegration):
"""A cog to display the console logs, with buttons and filter options, and to send commands errors in configured channels!"""

__authors__: typing.List[str] = ["AAA3A", "Tobotimus"]

def __init__(self, bot: Red) -> None:
super().__init__(bot=bot)
self.__authors__: typing.List[str] = ["AAA3A", "Tobotimus"]

self.config: Config = Config.get_conf(
self,
identifier=205192943327321000143939875896557571750,
force_registration=True,
)
self.consolelogs_channel: typing.Dict[str, typing.Union[bool, typing.List[str]]] = {
"enabled": False,
"global_errors": True,
"prefixed_commands_errors": True,
"slash_commands_errors": True,
"dpy_ignored_exceptions": False,
"full_console": False,
"guild_invite": True,
"ignored_cogs": [],
}
self.config.register_channel(**self.consolelogs_channel)
self.config.register_channel(
enabled=False,
global_errors=True,
prefixed_commands_errors=True,
slash_commands_errors=True,
dpy_ignored_exceptions=False,
full_console=False,
guild_invite=True,
ignored_cogs=[],
)

self.RED_INTRO: str = None
self._last_console_log_sent_timestamp: int = None
Expand Down Expand Up @@ -229,14 +229,6 @@ def console_logs(self) -> typing.List[ConsoleLog]:

return console_logs

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}

async def send_console_logs(
self,
ctx: commands.Context,
Expand Down
11 changes: 0 additions & 11 deletions ctxvar/ctxvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,6 @@ async def convert(
class CtxVar(Cog):
"""A cog to list and display the contents of all sub-functions of `ctx`!"""

def __init__(self, bot: Red) -> None:
super().__init__(bot=bot)

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}

@commands.is_owner()
@commands.hybrid_group()
async def ctxvar(self, ctx: commands.Context) -> None:
Expand Down
26 changes: 9 additions & 17 deletions dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,22 @@ class Dashboard(Cog):
⚠️ This package is a fork of Neuro Assassin's work, and isn't endorsed by the Org at all.
"""

__authors__: typing.List[str] = ["Neuro Assassin", "AAA3A"]

def __init__(self, bot: Red) -> None:
super().__init__(bot=bot)
self.__authors__: typing.List[str] = ["Neuro Assassin", "AAA3A"]

self.config: Config = Config.get_conf(
self,
identifier=205192943327321000143939875896557571750,
force_registration=True,
)
self.CONFIG_SCHEMA: int = 2
self.dashboard_global: typing.Dict[str, typing.Any] = {
"CONFIG_SCHEMA": None,
"all_in_one": False,
"flask_flags": [],
"webserver": {
self.config.register_global(
CONFIG_SCHEMA=None,
all_in_one=False,
flask_flags=[],
webserver={
"core": {
"secret_key": None,
"jwt_secret_key": None,
Expand Down Expand Up @@ -168,9 +169,8 @@ def __init__(self, bot: Red) -> None:
],
},
"disabled_third_parties": [],
},
}
self.config.register_global(**self.dashboard_global)
}
)

_settings: typing.Dict[str, typing.Dict[str, typing.Any]] = {
"all_in_one": {
Expand Down Expand Up @@ -288,14 +288,6 @@ async def cog_unload(self) -> None:
await asyncio.to_thread(self.app.tasks_manager.stop_tasks)
await super().cog_unload()

async def red_delete_data_for_user(self, *args, **kwargs) -> None:
"""Nothing to delete."""
return

async def red_get_data_for_user(self, *args, **kwargs) -> typing.Dict[str, typing.Any]:
"""Nothing to get."""
return {}

async def create_app(self, flask_flags: str) -> None:
await self.bot.wait_until_red_ready()
if await self.config.webserver.core.secret_key() is None:
Expand Down

0 comments on commit b9fa9a4

Please sign in to comment.