1
0
Fork 0
mirror of synced 2024-05-17 19:12:33 +12:00

Printing out the time left when a command is on cooldown

This commit is contained in:
phxntxm 2016-08-03 20:31:38 -05:00
parent c2a24887e9
commit c975e2b50c
3 changed files with 11 additions and 11 deletions

16
bot.py
View file

@ -43,14 +43,15 @@ async def on_ready():
if not hasattr(bot, 'uptime'):
bot.uptime = datetime.datetime.utcnow()
@bot.event
async def on_member_join(member):
notifications = config.getContent('user_notifications') or {}
server_notifications = notifications.get(member.server.id)
if not server_notifications:
return
channel = discord.utils.get(member.server.channels,id=server_notifications)
channel = discord.utils.get(member.server.channels, id=server_notifications)
await bot.send_message(channel, "Welcome to the '{0.server.name}' server {0.mention}!".format(member))
@ -60,10 +61,11 @@ async def on_member_remove(member):
server_notifications = notifications.get(member.server.id)
if not server_notifications:
return
channel = discord.utils.get(member.server.channels,id=server_notifications)
channel = discord.utils.get(member.server.channels, id=server_notifications)
await bot.send_message(channel,
"{0} has left the server, I hope it wasn't because of something I said :c".format(member.display_name))
"{0} has left the server, I hope it wasn't because of something I said :c".format(
member.display_name))
@bot.event
@ -72,6 +74,7 @@ async def on_message(message):
return
await bot.process_commands(message)
@bot.event
async def on_command_error(error, ctx):
if isinstance(error, commands.BadArgument):
@ -81,10 +84,9 @@ async def on_command_error(error, ctx):
fmt = "You can't tell me what to do!"
await bot.send_message(ctx.message.channel, fmt)
elif isinstance(error, commands.CommandOnCooldown):
fmt = "This command is on cooldown! Hold your horses! >:c"
fmt = "This command is on cooldown! Hold your horses! >:c\nTry again in {}".format(error.retry_after)
await bot.send_message(ctx.message.channel, fmt)
elif not isinstance(error, commands.CommandNotFound):
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
with open("/home/phxntx5/public_html/Bonfire/error_log", 'a') as f:
print('In {0.command.qualified_name}:'.format(ctx), file=f)
traceback.print_tb(error.original.__traceback__, file=f)

View file

@ -97,13 +97,12 @@ class Interaction:
battling = config.getContent('battling') or {}
battling[ctx.message.author.id] = ctx.message.mentions[0].id
config.saveContent('battling',battling)
config.saveContent('battling', battling)
fmt = "{0.mention} has challenged you to a battle {1.mention}\n!accept or !decline"
await self.bot.say(fmt.format(ctx.message.author, player2))
await self.bot.delete_message(ctx.message)
config.loop.call_later(180,battlingOff,ctx.message.author.id)
@commands.command(pass_context=True, no_pm=True)
@checks.customPermsOrRole(send_messages=True)
@ -156,7 +155,7 @@ class Interaction:
battlingOff(ctx.message.author.id)
@commands.command(pass_context=True, no_pm=True)
@commands.cooldown(1,180,BucketType.user)
@commands.cooldown(1, 180, BucketType.user)
@checks.customPermsOrRole(send_messages=True)
async def boop(self, ctx, boopee: discord.Member):
"""Boops the mentioned person"""

View file

@ -212,4 +212,3 @@ class Roles:
def setup(bot):
bot.add_cog(Roles(bot))