Skip to content

Commit

Permalink
perfected BotEssentials integreation with the new infrstrcture (fixing
Browse files Browse the repository at this point in the history
…#30 and giving a workaround for #29 )
  • Loading branch information
s0lst1ce committed Jun 2, 2019
1 parent 0fd7e7b commit 7f22e13
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
12 changes: 8 additions & 4 deletions BotEssentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -42,21 +44,23 @@ 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):
'''This command responds with the current latency.'''
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()
Expand Down
14 changes: 12 additions & 2 deletions Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7f22e13

Please sign in to comment.