Skip to content
This repository has been archived by the owner on Aug 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #36 from Deivedux/dev
Browse files Browse the repository at this point in the history
Fixed caching errors
  • Loading branch information
Deivedux authored May 9, 2019
2 parents 4f2ecd3 + 4b2917f commit 6cd9e8c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cogs/AntiFarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ async def on_guild_join(self, guild):

@commands.Cog.listener()
async def on_member_join(self, member):
if farm_check(guild):
if farm_check(member.guild):
await member.guild.leave()

@commands.Cog.listener()
async def on_member_remove(self, member):
if farm_check(guild):
if farm_check(member.guild):
await member.guild.leave()


Expand Down
14 changes: 12 additions & 2 deletions cogs/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def __init__(self, bot):

@commands.Cog.listener()
async def on_ready(self):
for guild in self.bot.guilds:
try:
DBService.exec("INSERT INTO ServerConfig (Guild) VALUES (" + str(guild.id) + ")")
except Exception:
continue

server_config_raw = DBService.exec("SELECT * FROM ServerConfig").fetchall()
for i in server_config_raw:
cache_guild(i)

guild_ids = [guild.id for guild in self.bot.guilds]
cached_guilds = [i for i in server_config.keys()]

Expand All @@ -78,11 +88,11 @@ async def on_guild_join(self, guild):
db_response = DBService.exec("SELECT * FROM ServerConfig WHERE Guild = " + str(guild.id)).fetchone()
cache_guild(db_response)

@commands.Cog.listener()
'''@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(content = error_string + ' **Please wait ' + str(round(error.retry_after, 1)) + ' seconds before invoking this again.**', delete_after = 5)

'''
@commands.Cog.listener()
async def on_raw_reaction_add(self, payload):
if str(payload.emoji) == '💬' and payload.user_id not in blacklist_ids and not self.bot.get_guild(payload.guild_id).get_member(payload.user_id).bot and server_config[payload.guild_id]['on_reaction']:
Expand Down
5 changes: 4 additions & 1 deletion quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
async def get_prefix(bot, message):
if message.guild:
try:
return commands.when_mentioned_or(server_config['prefix'][message.guild.id])(bot, message)
if server_config[message.guild.id]['prefix']:
return commands.when_mentioned_or(server_config[message.guild.id]['prefix'])(bot, message)
else:
return commands.when_mentioned_or(default_prefix)(bot, message)
except KeyError:
return commands.when_mentioned_or(default_prefix)(bot, message)
else:
Expand Down

0 comments on commit 6cd9e8c

Please sign in to comment.