Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Add members extension with join/leave notification
Browse files Browse the repository at this point in the history
  • Loading branch information
TitusKirch committed Sep 27, 2019
1 parent 9c5e33a commit e5bbfd2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions bot.py
Expand Up @@ -5,6 +5,7 @@
extensions = (
'cogs.admin',
'cogs.general',
'cogs.members'
)

class UninterestingBot(commands.AutoShardedBot):
Expand Down
25 changes: 25 additions & 0 deletions cogs/members.py
@@ -0,0 +1,25 @@
import discord
from discord.ext import commands
from utilities import getConfig

class Members(commands.Cog, name='Members'):
def __init__(self, bot):
self.bot = bot
self.config = getConfig()

@commands.Cog.listener()
async def on_member_join(self, member):
if self.config['guild']['history_channel'] > 0:
channel = member.guild.get_channel(self.config['guild']['history_channel'])
if channel != None:
await channel.send('**Welcome {0.mention} :tada:**'.format(member))

@commands.Cog.listener()
async def on_member_remove(self, member):
if self.config['guild']['history_channel'] > 0:
channel = member.guild.get_channel(self.config['guild']['history_channel'])
if channel != None:
await channel.send('*Bye {0.mention} :sleepy:*'.format(member))

def setup(bot):
bot.add_cog(Members(bot))
3 changes: 3 additions & 0 deletions config_default.ini
Expand Up @@ -2,3 +2,6 @@
token = myBotToken
command_prefix = !
game_name = uninteresting.dev

[guild]
history_channel = 0

0 comments on commit e5bbfd2

Please sign in to comment.