Add restart command and processing

This commit is contained in:
Dustin Pianalto 2018-06-14 10:25:26 -08:00
parent 3a76598766
commit 449c3bfe18
2 changed files with 18 additions and 0 deletions

View File

@ -71,6 +71,12 @@ class SebiMachine(commands.Bot, LoadConfig, Loggable):
async def on_ready(self): async def on_ready(self):
"""On ready function""" """On ready function"""
self.maintenance and self.logger.warning('MAINTENANCE ACTIVE') self.maintenance and self.logger.warning('MAINTENANCE ACTIVE')
with open(f'src/config/reboot', 'r') as f:
reboot = f.readlines()
if int(reboot[0]) == 1:
await self.get_channel(int(reboot[1])).send('Restart Finished.')
with open(f'src/config/reboot', 'w') as f:
f.write(f'0')
async def on_command_error(self, ctx, error): async def on_command_error(self, ctx, error):
""" """

View File

@ -5,6 +5,7 @@ from discord.ext import commands
import discord import discord
import traceback import traceback
import aiofiles import aiofiles
import os
class Upload: class Upload:
""" """
@ -114,5 +115,16 @@ class Upload:
await ctx.send("Extension not found") await ctx.send("Extension not found")
@commands.command(hidden=True)
async def reboot(self, ctx):
if ctx.author.id not in self.bot.ownerlist:
return await ctx.send('Only my contributors can use me like this :blush:', delete_after=10)
await ctx.send('Sebi-Machine is restarting.')
with open(f'src/config/reboot', 'w') as f:
f.write(f'1\n{ctx.channel.id}')
# noinspection PyProtectedMember
os._exit(1)
def setup(bot): def setup(bot):
bot.add_cog(Upload(bot)) bot.add_cog(Upload(bot))