Skip to content

Commit

Permalink
feat: cmd to get welcome message
Browse files Browse the repository at this point in the history
  • Loading branch information
Borketh committed Sep 25, 2024
1 parent 58bda1e commit ab4e095
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions fred/cogs/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions fred/fred.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
1 change: 0 additions & 1 deletion fred/fred_commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions fred/fred_commands/_baseclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 14 additions & 1 deletion fred/fred_commands/bot_meta.py
Original file line number Diff line number Diff line change
@@ -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):

Expand Down Expand Up @@ -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):
Expand All @@ -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 :(")

Expand Down

0 comments on commit ab4e095

Please sign in to comment.