Add restart command and processing
This commit is contained in:
parent
3a76598766
commit
449c3bfe18
@ -71,6 +71,12 @@ class SebiMachine(commands.Bot, LoadConfig, Loggable):
|
||||
async def on_ready(self):
|
||||
"""On ready function"""
|
||||
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):
|
||||
"""
|
||||
|
||||
@ -5,6 +5,7 @@ from discord.ext import commands
|
||||
import discord
|
||||
import traceback
|
||||
import aiofiles
|
||||
import os
|
||||
|
||||
class Upload:
|
||||
"""
|
||||
@ -114,5 +115,16 @@ class Upload:
|
||||
|
||||
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):
|
||||
bot.add_cog(Upload(bot))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user