Added exception if the person hasn't booped anyone
This commit is contained in:
parent
0323678d67
commit
9a516b0628
|
@ -23,30 +23,35 @@ class Stats:
|
|||
await self.bot.say("{0} you have booped {1} the most amount of times, coming in at {2} times".format(
|
||||
ctx.message.author.mention, member.mention, result.get('amount')))
|
||||
config.closeConnection()
|
||||
except pymysql.ProgrammingError:
|
||||
await self.bot.say("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention))
|
||||
except Exception as e:
|
||||
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
|
||||
await self.bot.say(fmt.format(type(e).__name__, e))
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def listboops(self, ctx):
|
||||
"""Lists all the users you have booped and the amount of times"""
|
||||
members = ctx.message.server.members
|
||||
cursor = config.getCursor()
|
||||
cursor.execute('use {}'.format(config.db_boops))
|
||||
sql = "select * from `{}`".format(ctx.message.author.id)
|
||||
cursor.execute(sql)
|
||||
result = cursor.fetchall()
|
||||
if result is None:
|
||||
await self.bot.say("You have not booped anyone!")
|
||||
return
|
||||
output = "You have booped:"
|
||||
for r in result:
|
||||
member = find(lambda m: m.id == r['id'], self.bot.get_all_members())
|
||||
amount = r['amount']
|
||||
if member in members:
|
||||
output += "\n{0.name}: {1} times".format(member,amount)
|
||||
config.closeConnection()
|
||||
await self.bot.say("```{}```".format(output))
|
||||
try:
|
||||
"""Lists all the users you have booped and the amount of times"""
|
||||
members = ctx.message.server.members
|
||||
cursor = config.getCursor()
|
||||
cursor.execute('use {}'.format(config.db_boops))
|
||||
sql = "select * from `{}`".format(ctx.message.author.id)
|
||||
cursor.execute(sql)
|
||||
result = cursor.fetchall()
|
||||
if result is None:
|
||||
await self.bot.say("You have not booped anyone!")
|
||||
return
|
||||
output = "You have booped:"
|
||||
for r in result:
|
||||
member = find(lambda m: m.id == r['id'], self.bot.get_all_members())
|
||||
amount = r['amount']
|
||||
if member in members:
|
||||
output += "\n{0.name}: {1} times".format(member,amount)
|
||||
config.closeConnection()
|
||||
await self.bot.say("```{}```".format(output))
|
||||
except pymysql.ProgrammingError:
|
||||
await self.bot.say("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention))
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def mostwins(self, ctx):
|
||||
|
|
Loading…
Reference in a new issue