mirror of
https://github.com/Specoolazius/mcserver-discordbot.git
synced 2025-10-04 02:40:32 +02:00
workz
This commit is contained in:
13
bot/extensions/developer.py
Normal file
13
bot/extensions/developer.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import discord
|
||||
|
||||
from libs import ServerBot
|
||||
|
||||
|
||||
class Developer(discord.Cog):
|
||||
|
||||
def __init__(self, bot: ServerBot):
|
||||
self.bot = bot
|
||||
|
||||
|
||||
def setup(bot: ServerBot):
|
||||
bot.add_cog(Developer(bot))
|
37
bot/extensions/executer.py
Normal file
37
bot/extensions/executer.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import asyncio
|
||||
import os.path
|
||||
|
||||
import discord
|
||||
from discord.commands import slash_command
|
||||
|
||||
from libs import ServerBot
|
||||
|
||||
|
||||
class Executer(discord.Cog):
|
||||
|
||||
def __init__(self, bot: ServerBot):
|
||||
self.bot = bot
|
||||
|
||||
@slash_command(name='start')
|
||||
async def __start_server(self, ctx: discord.ApplicationContext) -> None:
|
||||
await ctx.defer()
|
||||
|
||||
await asyncio.create_subprocess_exec(
|
||||
os.path.join('scripts', 'start-server.sh'),
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
|
||||
await ctx.respond('starting server')
|
||||
|
||||
@slash_command(name='stop')
|
||||
async def __stop_server(self, ctx: discord.ApplicationContext) -> None:
|
||||
if ctx.user.id not in self.bot.admin_ids:
|
||||
await ctx.respond('You don\'t have permissions to do that', ephemeral=True)
|
||||
return
|
||||
|
||||
await ctx.respond('Stopping server')
|
||||
|
||||
|
||||
def setup(bot: ServerBot):
|
||||
bot.add_cog(Executer(bot))
|
Reference in New Issue
Block a user