From 45ab47bb756db395708bc60b9ff32fb24a929c00 Mon Sep 17 00:00:00 2001 From: phxntxm Date: Fri, 8 Jul 2016 20:42:33 -0500 Subject: [PATCH] Made function variables more explicit, for the help command to be more obvious --- bot.py | 6 ++++++ cogs/interaction.py | 9 ++++----- cogs/owner.py | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bot.py b/bot.py index 118e05b..778b5c8 100644 --- a/bot.py +++ b/bot.py @@ -41,6 +41,12 @@ async def on_member_join(member): async def on_member_remove(member): await bot.say("{0} has left the server, I hope it wasn't because of something I said :c".format(member)) + +@bot.event +async def on_command_error(error, ctx): + fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```' + await bot.say(fmt.format(type(e).__name__, e)) + if __name__ == '__main__': for e in extensions: bot.load_extension(e) diff --git a/cogs/interaction.py b/cogs/interaction.py index 43af7e2..a91cac0 100644 --- a/cogs/interaction.py +++ b/cogs/interaction.py @@ -2,6 +2,7 @@ from discord.ext import commands from .utils import checks from .utils import config from threading import Timer +import discord import random battling = False @@ -58,7 +59,7 @@ class Interaction: self.bot = bot @commands.command(pass_context=True, no_pm=True) - async def battle(self, ctx): + async def battle(self, ctx, player2: discord.Member): """Challenges the mentioned user to a battle""" try: global battleP1 @@ -72,7 +73,6 @@ class Interaction: if len(ctx.message.mentions) > 1: await self.bot.say("You cannot battle more than one person at once!") return - player2 = ctx.message.mentions[0] if ctx.message.author.id == player2.id: await self.bot.say("Why would you want to battle yourself? Suicide is not the answer") return @@ -125,17 +125,16 @@ class Interaction: await self.bot.say(fmt.format(type(e).__name__, e)) @commands.command(pass_context=True, no_pm=True) - async def boop(self, ctx): + async def boop(self, ctx, boopee: discord.Member): """Boops the mentioned person""" try: + booper = ctx.message.author if len(ctx.message.mentions) == 0: await self.bot.say("You must mention someone in the room " + ctx.message.author.mention + "!") return if len(ctx.message.mentions) > 1: await self.bot.say("You cannot boop more than one person at once!") return - boopee = ctx.message.mentions[0] - booper = ctx.message.author if boopee.id == booper.id: await self.bot.say("You can't boop yourself! Silly...") return diff --git a/cogs/owner.py b/cogs/owner.py index 2fe975e..11cc826 100644 --- a/cogs/owner.py +++ b/cogs/owner.py @@ -68,7 +68,7 @@ class Owner: @commands.command() @checks.isOwner() - async def avatar(self, content): + async def avatar(self, content: str): """Changes the avatar for the bot to the filename following the command""" try: file = '/home/phxntx5/public_html/bot/images/' + content @@ -80,7 +80,7 @@ class Owner: @commands.command() @checks.isOwner() - async def name(self, newNick): + async def name(self, newNick: str): """Changes the bot's name""" try: await self.bot.edit_profile(username=newNick)