Disable/enable commands, uptime fix

This commit is contained in:
Twentysix
2016-05-06 20:56:41 +02:00
parent 111ed83d89
commit 399ddeb886
2 changed files with 76 additions and 3 deletions

8
red.py
View File

@@ -38,7 +38,8 @@ async def on_ready():
users = str(len(set(bot.get_all_members())))
servers = str(len(bot.servers))
channels = str(len([c for c in bot.get_all_channels()]))
bot.uptime = int(time.perf_counter())
if not "uptime" in dir(bot): #prevents reset in case of reconnection
bot.uptime = int(time.perf_counter())
print('------')
print(bot.user.name + " is now online.")
print('------')
@@ -55,6 +56,7 @@ async def on_ready():
bot.oauth_url = url
print(url)
print("------")
await bot.get_cog('Owner').disable_commands()
@bot.event
@@ -74,6 +76,8 @@ async def on_command_error(error, ctx):
await send_cmd_help(ctx)
elif isinstance(error, commands.BadArgument):
await send_cmd_help(ctx)
elif isinstance(error, commands.DisabledCommand):
await bot.send_message(ctx.message.channel, "That command is disabled.")
async def send_cmd_help(ctx):
if ctx.invoked_subcommand:
@@ -379,4 +383,4 @@ if __name__ == '__main__':
logger.error(traceback.format_exc())
loop.run_until_complete(bot.logout())
finally:
loop.close()
loop.close()