mirror of
https://github.com/Specoolazius/mcserver-discordbot.git
synced 2025-09-13 18:02:54 +02:00
Compare commits
7 Commits
9ac6d5ecb1
...
main
Author | SHA1 | Date | |
---|---|---|---|
e03066341a | |||
206bafd302 | |||
6614accb1d | |||
6becf331e0 | |||
bf4cabb122 | |||
58416ab8d3 | |||
8daf6fb405 |
@@ -1,3 +1,3 @@
|
|||||||
# mcserver-discordbot
|
# mcserver-discordbot
|
||||||
|
|
||||||
Currenlty in development. Readme will follow soon.
|
Currently in development. Readme will follow soon.
|
||||||
|
@@ -26,7 +26,7 @@ class Admin(discord.Cog):
|
|||||||
|
|
||||||
@__dev_group.command(name='update')
|
@__dev_group.command(name='update')
|
||||||
async def __update_bot(self, ctx: discord.ApplicationContext) -> None:
|
async def __update_bot(self, ctx: discord.ApplicationContext) -> None:
|
||||||
await ctx.respond('starting update...')
|
await ctx.defer()
|
||||||
|
|
||||||
if 0 == await self.bot.execute_shell('update.sh'):
|
if 0 == await self.bot.execute_shell('update.sh'):
|
||||||
await ctx.respond('Updated bot from https://github.com/Specoolazius/mcserver-discordbot\n'
|
await ctx.respond('Updated bot from https://github.com/Specoolazius/mcserver-discordbot\n'
|
||||||
|
@@ -3,6 +3,7 @@ Project is under GNU GENERAL PUBLIC LICENSE 3.0
|
|||||||
|
|
||||||
2022, created by Specoolazius
|
2022, created by Specoolazius
|
||||||
"""
|
"""
|
||||||
|
import os.path
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.commands import slash_command
|
from discord.commands import slash_command
|
||||||
@@ -21,9 +22,27 @@ class StartStop(discord.Cog):
|
|||||||
|
|
||||||
@slash_command(name='start')
|
@slash_command(name='start')
|
||||||
async def __execute_start(self, ctx: discord.ApplicationContext) -> None:
|
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')
|
@slash_command(name='stop')
|
||||||
async def __execute_stop(self, ctx: discord.ApplicationContext) -> None:
|
async def __execute_stop(self, ctx: discord.ApplicationContext) -> None:
|
||||||
returncode = None
|
await ctx.defer()
|
||||||
# hi
|
await ctx.respond('Not implemented yet')
|
||||||
|
@@ -58,6 +58,8 @@ class Presence(object):
|
|||||||
if self.bot.is_server_starting and self.bot.last_start + self.bot.config.server_start_timout < time.time():
|
if self.bot.is_server_starting and self.bot.last_start + self.bot.config.server_start_timout < time.time():
|
||||||
self.bot.is_server_starting = False
|
self.bot.is_server_starting = False
|
||||||
|
|
||||||
|
self.bot.logger.debug('Resetting is_starting to False')
|
||||||
|
|
||||||
# ToDo: better presence
|
# ToDo: better presence
|
||||||
await self.bot.change_presence(
|
await self.bot.change_presence(
|
||||||
activity=discord.Activity(
|
activity=discord.Activity(
|
||||||
|
@@ -4,5 +4,5 @@
|
|||||||
#
|
#
|
||||||
# 2022, created by Specoolazius
|
# 2022, created by Specoolazius
|
||||||
|
|
||||||
cd ~/mcserver-discordbot/bot || exit;
|
cd /root/mcserver-discordbot/bot || exit;
|
||||||
python3 -O run.py
|
python3 -O run.py
|
||||||
|
@@ -8,3 +8,4 @@
|
|||||||
|
|
||||||
git stash
|
git stash
|
||||||
git pull --rebase origin
|
git pull --rebase origin
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ Requires=network.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=idle
|
Type=idle
|
||||||
ExecStart=/root/mcserver-discordbot/bot/run.sh
|
ExecStart=chmod +x /root/mcserver-discordbot/bot/run.sh && /root/mcserver-discordbot/bot/run.sh
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
|
Reference in New Issue
Block a user