You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 lines
1.1 KiB

import discord
import aiohttp
class Extension:
def __init__(self, core):
@core.tree.command(name = "rcon", description = "Вызвать команду на сервере")
@discord.app_commands.describe(server="Нужным сервер в формате srv1", command="Команда исполнения")
async def rcon_command(
interaction: discord.Interaction,
server: str,
command: str
):
await interaction.response.defer(thinking=True)
steam64 = await core.GetSteam64OfDiscord(interaction.user)
if not server in core.stats.get("servers", {}).keys():
return await interaction.followup.send(f"Сервер с таким индификатором не существует, введи существующий из предложенных:\n{' '.join(core.stats.get('servers', {}).keys())}", ephemeral=False)
async with aiohttp.ClientSession(cookies={"secretkey":core.secret_key, "steam64":steam64}) as session:
async with session.post(f"{core.backend_url}/api/admin/rcon?srv={server}&command={command}", ssl=False) as response:
return await interaction.followup.send(f'{await response.text()}', ephemeral=False)