mirror of
https://github.com/Specoolazius/mcserver-discordbot.git
synced 2024-11-24 22:29:42 +01:00
implemented start command
This commit is contained in:
parent
bf4cabb122
commit
6becf331e0
@ -3,6 +3,7 @@ Project is under GNU GENERAL PUBLIC LICENSE 3.0
|
||||
|
||||
2022, created by Specoolazius
|
||||
"""
|
||||
import os.path
|
||||
|
||||
import discord
|
||||
from discord.commands import slash_command
|
||||
@ -21,9 +22,27 @@ class StartStop(discord.Cog):
|
||||
|
||||
@slash_command(name='start')
|
||||
async def __execute_start(self, ctx: discord.ApplicationContext) -> None:
|
||||
returncode = None
|
||||
await ctx.defer()
|
||||
self.bot.is_server_starting = True
|
||||
|
||||
try:
|
||||
returncode = await self.bot.execute_shell('start.sh')
|
||||
self.bot.logger.info(f'Executed start.sh with exit code {returncode}')
|
||||
|
||||
except Exception as e:
|
||||
self.bot.logger.error(
|
||||
f'Failed to run start.sh\n'
|
||||
f'Error: {e}'
|
||||
)
|
||||
await ctx.respond(
|
||||
f'Failed to execute start.sh\n'
|
||||
f'Check {os.path.join(self.bot.config.log_path, "discord.log")} for more detailed information'
|
||||
)
|
||||
|
||||
else:
|
||||
await ctx.respond('Server is starting')
|
||||
|
||||
@slash_command(name='stop')
|
||||
async def __execute_stop(self, ctx: discord.ApplicationContext) -> None:
|
||||
returncode = None
|
||||
# hi
|
||||
await ctx.defer()
|
||||
await ctx.respond('Not implemented yet')
|
||||
|
Loading…
Reference in New Issue
Block a user