From ab4e095e83e3d989d88f6980312c0968e5ba321b Mon Sep 17 00:00:00 2001 From: borketh Date: Wed, 25 Sep 2024 12:20:42 -0400 Subject: [PATCH] feat: cmd to get welcome message --- fred/cogs/welcome.py | 3 +++ fred/fred.py | 4 ++++ fred/fred_commands/__init__.py | 1 - fred/fred_commands/_baseclass.py | 10 ++++++++++ fred/fred_commands/bot_meta.py | 15 ++++++++++++++- 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/fred/cogs/welcome.py b/fred/cogs/welcome.py index 365fdf0..4db64ab 100644 --- a/fred/cogs/welcome.py +++ b/fred/cogs/welcome.py @@ -10,6 +10,9 @@ async def on_member_join(self, member: Member): self.logger.info("Processing a member joining", extra=common.user_info(member)) + await self.send_welcome_message(member) + + async def send_welcome_message(self, member: Member): if welcome := config.Misc.fetch("welcome_message"): self.logger.info("Sending the welcome message to a new member", extra=common.user_info(member)) await self.bot.send_DM(member, welcome) diff --git a/fred/fred.py b/fred/fred.py index 33cfbe8..1e6a86b 100644 --- a/fred/fred.py +++ b/fred/fred.py @@ -118,6 +118,10 @@ def Crashes(self) -> crashes.Crashes: def DialogFlow(self) -> dialogflow.DialogFlow: return self.get_cog("DialogFlow") # noqa + @property + def Welcome(self) -> welcome.Welcome: + return self.get_cog("Welcome") # noqa + async def on_error(self, event_method: str, *args, **kwargs): exc_type, value, tb = sys.exc_info() if event_method == "on_message": diff --git a/fred/fred_commands/__init__.py b/fred/fred_commands/__init__.py index b17bbe7..24182f9 100644 --- a/fred/fred_commands/__init__.py +++ b/fred/fred_commands/__init__.py @@ -10,7 +10,6 @@ import nextcord from algoliasearch.search_client import SearchClient -from nextcord import Attachment from nextcord.ext.commands.view import StringView from ._baseclass import BaseCmds, common, config, commands diff --git a/fred/fred_commands/_baseclass.py b/fred/fred_commands/_baseclass.py index 4537702..338c8de 100644 --- a/fred/fred_commands/_baseclass.py +++ b/fred/fred_commands/_baseclass.py @@ -67,6 +67,16 @@ async def modify(self, ctx: commands.Context): await self.bot.reply_to_msg(ctx.message, "Invalid sub command passed...") return + @commands.group() + @commands.check(common.l4_only) + async def get(self, ctx: commands.Context): + """Usage: `get (subcommand) [args]` + Purpose: Gets something (duh). Check individual subcommands for specifics. + Notes: Limited to permission level 4 and above.""" + if ctx.invoked_subcommand is None: + await self.bot.reply_to_msg(ctx.message, "Invalid sub command passed...") + return + class SearchFlags(commands.FlagConverter, delimiter="=", prefix="-"): column: str = "name" diff --git a/fred/fred_commands/bot_meta.py b/fred/fred_commands/bot_meta.py index 129ca55..7a9c133 100644 --- a/fred/fred_commands/bot_meta.py +++ b/fred/fred_commands/bot_meta.py @@ -1,5 +1,12 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + from ._baseclass import BaseCmds, commands, config, common +if TYPE_CHECKING: + from ..fred import Bot + class BotCmds(BaseCmds): @@ -34,6 +41,11 @@ async def set_latest_info(self, ctx: commands.Context, latest_info: str): config.Misc.change("latest_info", latest_info) await self.bot.reply_to_msg(ctx.message, "The latest info message has been changed!") + @BaseCmds.get.command(name="welcome") + async def get_welcome(self, ctx: commands.Context): + bot: Bot = ctx.bot + await bot.Welcome.send_welcome_message(ctx.author) + @commands.check(common.mod_only) @BaseCmds.set.command(name="main_guild") async def set_main_guild(self, ctx: commands.Context, guild_id: int = None): @@ -56,10 +68,11 @@ async def prefix(self, ctx: commands.Context, *, prefix: str): await self.bot.reply_to_msg(ctx.message, f"Prefix changed to {prefix}.") @BaseCmds.set.command(name="owo") + @commands.check(common.mod_only) async def owo(self, ctx: commands.Context): """Usage: `set owo` Purpose: toggle owo - Notes: owo what's this? you need to be engineer or above to use this""" + Notes: owo what's this? you need to be a mod to use this :3""" self.bot.owo = not self.bot.owo await ctx.reply("OwO" if self.bot.owo else "no owo :(")