Join and Leave Messages

This commit is contained in:
Akumatic 2018-06-21 00:26:10 +02:00
parent bd048acc95
commit dc595f62b6

View File

@ -5,7 +5,7 @@ import discord
class User(): class User():
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@commands.command() @commands.command()
async def greetMe(self, ctx): async def greetMe(self, ctx):
"""Prints the greeting text a user receives by joining the server""" """Prints the greeting text a user receives by joining the server"""
@ -24,7 +24,6 @@ class User():
Your original message gets deleted and sent to a private suggestion channel. Your original message gets deleted and sent to a private suggestion channel.
If no suggestion channel is specified, it will be sent to the owner instead.""" If no suggestion channel is specified, it will be sent to the owner instead."""
if(ctx.guild == None): if(ctx.guild == None):
return await ctx.send("This command can only be used within a server") return await ctx.send("This command can only be used within a server")
if(msg == None): if(msg == None):
@ -39,6 +38,25 @@ class User():
else: else:
await ctx.guild.get_member(ctx.guild.owner.id).send(embed=e) await ctx.guild.get_member(ctx.guild.owner.id).send(embed=e)
async def on_member_join(self, member):
await member.send(s[str(member.guild.id)]["joinMessage"])
if(s[str(member.guild.id)]["modChannel"] != 0):
e = discord.Embed(color=0x32c832)
e.set_author(name = str(member) + " has joined the server.", icon_url=member.avatar_url)
e.add_field(name="ID", value=str(member.id), inline=False)
e.add_field(name="Mention", value=member.mention, inline=False)
chan = self.bot.get_channel(s[str(member.guild.id)]["modChannel"])
await chan.send(embed=e)
async def on_member_remove(self, member):
if(s[str(member.guild.id)]["modChannel"] != 0):
e = discord.Embed(color=0xc83232)
e.set_author(name = str(member) + " has left the server.", icon_url=member.avatar_url)
e.add_field(name="ID", value=str(member.id), inline=False)
e.add_field(name="Mention", value=member.mention, inline=False)
chan = self.bot.get_channel(s[str(member.guild.id)]["modChannel"])
await chan.send(embed=e)
#Setup #Setup
def setup(bot): def setup(bot):
bot.add_cog(User(bot)) bot.add_cog(User(bot))