This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add members extension with join/leave notification
- Loading branch information
1 parent
9c5e33a
commit e5bbfd2
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
token = myBotToken | ||
command_prefix = ! | ||
game_name = uninteresting.dev | ||
|
||
[guild] | ||
history_channel = 0 |