Printing out the time left when a command is on cooldown
This commit is contained in:
parent
c2a24887e9
commit
c975e2b50c
16
bot.py
16
bot.py
|
@ -43,14 +43,15 @@ async def on_ready():
|
||||||
if not hasattr(bot, 'uptime'):
|
if not hasattr(bot, 'uptime'):
|
||||||
bot.uptime = datetime.datetime.utcnow()
|
bot.uptime = datetime.datetime.utcnow()
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_member_join(member):
|
async def on_member_join(member):
|
||||||
notifications = config.getContent('user_notifications') or {}
|
notifications = config.getContent('user_notifications') or {}
|
||||||
server_notifications = notifications.get(member.server.id)
|
server_notifications = notifications.get(member.server.id)
|
||||||
if not server_notifications:
|
if not server_notifications:
|
||||||
return
|
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))
|
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)
|
server_notifications = notifications.get(member.server.id)
|
||||||
if not server_notifications:
|
if not server_notifications:
|
||||||
return
|
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,
|
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
|
@bot.event
|
||||||
|
@ -72,6 +74,7 @@ async def on_message(message):
|
||||||
return
|
return
|
||||||
await bot.process_commands(message)
|
await bot.process_commands(message)
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_command_error(error, ctx):
|
async def on_command_error(error, ctx):
|
||||||
if isinstance(error, commands.BadArgument):
|
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!"
|
fmt = "You can't tell me what to do!"
|
||||||
await bot.send_message(ctx.message.channel, fmt)
|
await bot.send_message(ctx.message.channel, fmt)
|
||||||
elif isinstance(error, commands.CommandOnCooldown):
|
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)
|
await bot.send_message(ctx.message.channel, fmt)
|
||||||
elif not isinstance(error, commands.CommandNotFound):
|
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:
|
with open("/home/phxntx5/public_html/Bonfire/error_log", 'a') as f:
|
||||||
print('In {0.command.qualified_name}:'.format(ctx), file=f)
|
print('In {0.command.qualified_name}:'.format(ctx), file=f)
|
||||||
traceback.print_tb(error.original.__traceback__, file=f)
|
traceback.print_tb(error.original.__traceback__, file=f)
|
||||||
|
|
|
@ -97,13 +97,12 @@ class Interaction:
|
||||||
|
|
||||||
battling = config.getContent('battling') or {}
|
battling = config.getContent('battling') or {}
|
||||||
battling[ctx.message.author.id] = ctx.message.mentions[0].id
|
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"
|
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.say(fmt.format(ctx.message.author, player2))
|
||||||
await self.bot.delete_message(ctx.message)
|
await self.bot.delete_message(ctx.message)
|
||||||
config.loop.call_later(180,battlingOff,ctx.message.author.id)
|
config.loop.call_later(180,battlingOff,ctx.message.author.id)
|
||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True, no_pm=True)
|
@commands.command(pass_context=True, no_pm=True)
|
||||||
@checks.customPermsOrRole(send_messages=True)
|
@checks.customPermsOrRole(send_messages=True)
|
||||||
|
@ -156,7 +155,7 @@ class Interaction:
|
||||||
battlingOff(ctx.message.author.id)
|
battlingOff(ctx.message.author.id)
|
||||||
|
|
||||||
@commands.command(pass_context=True, no_pm=True)
|
@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)
|
@checks.customPermsOrRole(send_messages=True)
|
||||||
async def boop(self, ctx, boopee: discord.Member):
|
async def boop(self, ctx, boopee: discord.Member):
|
||||||
"""Boops the mentioned person"""
|
"""Boops the mentioned person"""
|
||||||
|
|
|
@ -212,4 +212,3 @@ class Roles:
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Roles(bot))
|
bot.add_cog(Roles(bot))
|
||||||
|
|
Loading…
Reference in a new issue