Skip to content

Commit

Permalink
Refactor invite manager
Browse files Browse the repository at this point in the history
  • Loading branch information
caffeine-addictt committed Dec 14, 2023
1 parent 0ded28e commit 36303ea
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/cogs/invite_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import discord
from discord import app_commands
from discord.ext import commands
from typing import Optional

from src.utils import Embeds, Error
from src.config import Config
Expand All @@ -12,6 +12,9 @@ class Invite(commands.Cog):
Handles welcoming new members
"""

client: commands.Bot


def __init__(self, client: commands.Bot) -> None:
self.client = client

Expand All @@ -24,9 +27,9 @@ async def on_ready(self):
@commands.Cog.listener()
async def on_member_join(self, member: discord.Member):
guild = self.client.get_guild(Config.GUILD_ID)
welcome_channel = guild.get_channel(Config.WELCOME_CHANNEL_ID)
welcome_channel = guild and guild.get_channel(Config.WELCOME_CHANNEL_ID)

if welcome_channel:
if welcome_channel and isinstance(welcome_channel, discord.TextChannel):
await welcome_channel.send(member.mention, embed = Embeds(
title = member.global_name,
description = f'**Welcome to the server!** 🎉\n\nDon\'t forget to `git checkout `<#{Config.RULE_CHANNEL_ID}>'
Expand Down

0 comments on commit 36303ea

Please sign in to comment.