1
0
Fork 0
mirror of synced 2024-05-19 12:02:29 +12:00

Made function variables more explicit, for the help command to be more obvious

This commit is contained in:
phxntxm 2016-07-08 20:42:33 -05:00
parent 1f8b380b62
commit 45ab47bb75
3 changed files with 12 additions and 7 deletions

6
bot.py
View file

@ -41,6 +41,12 @@ async def on_member_join(member):
async def on_member_remove(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)) 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__': if __name__ == '__main__':
for e in extensions: for e in extensions:
bot.load_extension(e) bot.load_extension(e)

View file

@ -2,6 +2,7 @@ from discord.ext import commands
from .utils import checks from .utils import checks
from .utils import config from .utils import config
from threading import Timer from threading import Timer
import discord
import random import random
battling = False battling = False
@ -58,7 +59,7 @@ class Interaction:
self.bot = bot self.bot = bot
@commands.command(pass_context=True, no_pm=True) @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""" """Challenges the mentioned user to a battle"""
try: try:
global battleP1 global battleP1
@ -72,7 +73,6 @@ class Interaction:
if len(ctx.message.mentions) > 1: if len(ctx.message.mentions) > 1:
await self.bot.say("You cannot battle more than one person at once!") await self.bot.say("You cannot battle more than one person at once!")
return return
player2 = ctx.message.mentions[0]
if ctx.message.author.id == player2.id: if ctx.message.author.id == player2.id:
await self.bot.say("Why would you want to battle yourself? Suicide is not the answer") await self.bot.say("Why would you want to battle yourself? Suicide is not the answer")
return return
@ -125,17 +125,16 @@ class Interaction:
await self.bot.say(fmt.format(type(e).__name__, e)) await self.bot.say(fmt.format(type(e).__name__, e))
@commands.command(pass_context=True, no_pm=True) @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""" """Boops the mentioned person"""
try: try:
booper = ctx.message.author
if len(ctx.message.mentions) == 0: if len(ctx.message.mentions) == 0:
await self.bot.say("You must mention someone in the room " + ctx.message.author.mention + "!") await self.bot.say("You must mention someone in the room " + ctx.message.author.mention + "!")
return return
if len(ctx.message.mentions) > 1: if len(ctx.message.mentions) > 1:
await self.bot.say("You cannot boop more than one person at once!") await self.bot.say("You cannot boop more than one person at once!")
return return
boopee = ctx.message.mentions[0]
booper = ctx.message.author
if boopee.id == booper.id: if boopee.id == booper.id:
await self.bot.say("You can't boop yourself! Silly...") await self.bot.say("You can't boop yourself! Silly...")
return return

View file

@ -68,7 +68,7 @@ class Owner:
@commands.command() @commands.command()
@checks.isOwner() @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""" """Changes the avatar for the bot to the filename following the command"""
try: try:
file = '/home/phxntx5/public_html/bot/images/' + content file = '/home/phxntx5/public_html/bot/images/' + content
@ -80,7 +80,7 @@ class Owner:
@commands.command() @commands.command()
@checks.isOwner() @checks.isOwner()
async def name(self, newNick): async def name(self, newNick: str):
"""Changes the bot's name""" """Changes the bot's name"""
try: try:
await self.bot.edit_profile(username=newNick) await self.bot.edit_profile(username=newNick)