Compare commits
3 commits
98dccd919e
...
d0f71ffbec
Author | SHA1 | Date | |
---|---|---|---|
d0f71ffbec | |||
dd2a031084 | |||
26c0ad8b63 |
1 changed files with 7 additions and 17 deletions
|
@ -2,6 +2,7 @@ import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
import requests
|
import requests
|
||||||
|
from discord import ui
|
||||||
from redbot.core import commands, app_commands, Config
|
from redbot.core import commands, app_commands, Config
|
||||||
|
|
||||||
class Pterodactyl(commands.Cog):
|
class Pterodactyl(commands.Cog):
|
||||||
|
@ -108,14 +109,14 @@ class Pterodactyl(commands.Cog):
|
||||||
passed_info = [old_startup_args[0], old_startup_args[1], headers, put_data, new_put_data, interaction_message]
|
passed_info = [old_startup_args[0], old_startup_args[1], headers, put_data, new_put_data, interaction_message]
|
||||||
await interaction_message.edit(content="The server is already running! Are you sure you'd like to stop the server for updates?", view=self.UpdateButtons(timeout=180, passed_info=passed_info))
|
await interaction_message.edit(content="The server is already running! Are you sure you'd like to stop the server for updates?", view=self.UpdateButtons(timeout=180, passed_info=passed_info))
|
||||||
|
|
||||||
class UpdateButtons(discord.ui.View):
|
class UpdateButtons(ui.View):
|
||||||
def __init__(self, timeout, passed_info):
|
def __init__(self, timeout, passed_info):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.passed_info = passed_info
|
self.passed_info = passed_info
|
||||||
|
|
||||||
@discord.ui.button(label="Yes", style=discord.ButtonStyle.success)
|
@ui.button(label="Yes", style=discord.ButtonStyle.success)
|
||||||
async def yes_button(self, button:discord.ui.Button, interaction:discord.Interaction):
|
async def yes_button(self, button:ui.Button, interaction:discord.Interaction):
|
||||||
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), headers=headers, json={"signal": "stop"})
|
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), headers=self.passed_info[2], json={"signal": "stop"})
|
||||||
await interaction.response.edit_message("Server stopping...", view=None)
|
await interaction.response.edit_message("Server stopping...", view=None)
|
||||||
while True:
|
while True:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
|
@ -158,8 +159,8 @@ class Pterodactyl(commands.Cog):
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@discord.ui.button(label="No", style=discord.ButtonStyle.danger)
|
@ui.button(label="No", style=discord.ButtonStyle.danger)
|
||||||
async def no_button(self, button:discord.ui.Button, interaction:discord.Interaction):
|
async def no_button(self, button:ui.Button, interaction:discord.Interaction):
|
||||||
for button in self.children:
|
for button in self.children:
|
||||||
button.disabled = True
|
button.disabled = True
|
||||||
await interaction.response.edit_message(content=f"Command cancelled.", view=self)
|
await interaction.response.edit_message(content=f"Command cancelled.", view=self)
|
||||||
|
@ -266,14 +267,3 @@ class Pterodactyl(commands.Cog):
|
||||||
else:
|
else:
|
||||||
send = f"Configuration changed:\n{message}"
|
send = f"Configuration changed:\n{message}"
|
||||||
await interaction.response.send_message(send, ephemeral=True)
|
await interaction.response.send_message(send, ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
import requests
|
|
||||||
headers = {
|
|
||||||
"Authorization": "Bearer ptlc_9BVTvT41F7mNtG7YIqaxhOySf4Z8YDmVYwaITwwIbA7",
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"Accept": "Application/vnd.pterodactyl.v1+json"
|
|
||||||
}
|
|
||||||
request = requests.get("https://mc.bloom.host/api/client/servers/d6d05b41-4da5-4c5b-9ee6-6e25f61a596b/startup", headers=headers)
|
|
||||||
request_dict = request.json()
|
|
||||||
print(request_dict)
|
|
||||||
|
|
Reference in a new issue