diff --git a/BotEssentials.py b/BotEssentials.py index 8a32ff6..5a0a488 100644 --- a/BotEssentials.py +++ b/BotEssentials.py @@ -34,6 +34,8 @@ class BotEssentials(commands.Cog): """All of the essential methods all of our bots should have""" def __init__(self, bot): self.bot = bot + self.invite_url = "https://discord.gg/mpGM5cg" + @commands.Cog.listener() async def on_ready(self): @@ -42,13 +44,16 @@ async def on_ready(self): @commands.Cog.listener() async def on_member_join(self, member): local_logger.info("User {0.name}[{0.id}] joined {1.name}[{1.id}]".format(member, member.guild)) - await member.guild.system_channel.send("Welcome to {} {}! Please make sure to take a look at our {} and before asking a question, at the {}".format(member.guild.name, member.mention, CHANNELS["rules"].mention, CHANNELS["faq"].mention)) + welcome_msg = get_conf(member.guild.id)["messages"]["welcome"] + if welcome_msg != False: + await member.guild.system_channel.send(welcome_msg.format(member.mention)) @commands.Cog.listener() async def on_member_remove(self, member): local_logger.info("User {0.name}[{0.id}] left {1.name}[{1.id}]".format(member, member.guild)) - await member.guilg.system_channel.send("Goodbye {0.name} {1}, may your wandering be fun!".format(member, EMOJIS["wave"])) - + goodbye_msg = get_conf(member.guild.id)["messages"]["welcome"] + if goodbye_msg != False: + await member.guild.system_channel.send(goodbye_msg.format(member.mention)) @commands.command() async def ping(self, ctx): @@ -56,7 +61,6 @@ async def ping(self, ctx): latency = self.bot.latency await ctx.send("**Pong !** Latency of {0:.3f} seconds".format(latency)) - #Command that shuts down the bot @commands.command() @is_runner() diff --git a/Config.py b/Config.py index db95e03..e8a73ea 100644 --- a/Config.py +++ b/Config.py @@ -38,6 +38,8 @@ def __init__(self, bot): self.allowed_answers = {1:["yes", "y"], 0:["no", "n"]} + self.ad_msg = "I ({}) have recently been added to this server ! I hope I'll be useful for you. Hopefully you won't find me too many bugs. However if you do I would apreicate it if you could report them to the server ({}) where my developers are ~~partying~~ working hard to make me better ! This is also the place to share your thoughts on how to improve me. Have a nice day and maybe, see you there {}".format(self.bot.mention, self.invite_url, EMOJIS["wave"]) + @commands.group() @@ -242,7 +244,7 @@ async def cfg_welcome(self, ctx): while retry: - await self.config_channels[ctx.guild.id].send("Enter the message you'd like to be sent to the new users. If you want to mention them use `{}`") + await self.config_channels[ctx.guild.id].send("Enter the message you'd like to be sent to the new users. If you want to mention them use `{0}`") message = await self.bot.wait_for("message", check=self.is_answer) @@ -289,7 +291,7 @@ async def cfg_goodbye(self, ctx): while retry: - await self.config_channels[ctx.guild.id].send("Enter the message you'd like to be sent. If you want to mention them use `{}`") + await self.config_channels[ctx.guild.id].send("Enter the message you'd like to be sent. If you want to mention them use `{0}`") message = await self.bot.wait_for("message", check=self.is_answer) @@ -333,6 +335,14 @@ async def allow_ad(ctx): old_conf = get_conf(ctx.guild.id) old_conf["advertisement"] = reponse.channel_mentions[0].id + chan = dfind(lambda c: c.id==old_conf["advertisement"], ctx.guild.channels) + chan.send(self.ad_msg) + + #updating conf + update_conf(ctx.guild.id, old_conf) + + + except Exception as e: local_logger.exception(e) raise e