From c99416ede5f66849922137f65582f03e69d60599 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 14 Jul 2023 12:09:17 -0400 Subject: [PATCH] changed how modal works --- pterodactyl/ptero.py | 82 ++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/pterodactyl/ptero.py b/pterodactyl/ptero.py index 788d00f..46eb011 100644 --- a/pterodactyl/ptero.py +++ b/pterodactyl/ptero.py @@ -42,46 +42,46 @@ class Pterodactyl(commands.Cog): @app_commands.command() async def config(self, interaction: discord.Interaction): """Configures the Pterodactyl cog.""" - await interaction.response.send_modal(self.ConfigModal(interaction.guild)) + await interaction.response.send_modal(ConfigModal(interaction.guild)) - class ConfigModal(discord.ui.Modal, title="Pterodactyl Manager Configuration"): - def __init__(self, guild: discord.guild): - super().__init__() - self.guild = guild - base_url = discord.ui.TextInput( - label="Base URL", - placeholder="Input your Pterodactyl Panel's Base URL here, without HTTPS or HTTP.", - style=discord.TextStyle.paragraph, - required=False, - max_length=300 - ) - api_key = discord.ui.TextInput( - label="API Key", - placeholder="Input your Pterodactyl Client API Key here.", - style=discord.TextStyle.short, - required=False, - max_length=300 - ) - server_id = discord.ui.TextInput( - label="Server ID", - placeholder="Input your Pterodactyl server's Server ID here.", - style=discord.TextStyle.short, - required=False, - max_length=300 - ) +class ConfigModal(discord.ui.Modal, title="Pterodactyl Manager Configuration"): + def __init__(self, guild: discord.guild): + super().__init__() + self.guild = guild + base_url = discord.ui.TextInput( + label="Base URL", + placeholder="Input your Pterodactyl Panel's Base URL here, without HTTPS or HTTP.", + style=discord.TextStyle.paragraph, + required=False, + max_length=300 + ) + api_key = discord.ui.TextInput( + label="API Key", + placeholder="Input your Pterodactyl Client API Key here.", + style=discord.TextStyle.short, + required=False, + max_length=300 + ) + server_id = discord.ui.TextInput( + label="Server ID", + placeholder="Input your Pterodactyl server's Server ID here.", + style=discord.TextStyle.short, + required=False, + max_length=300 + ) - async def on_submit(self, interaction: discord.Interaction): - config_list = [await Pterodactyl.config.guild(interaction.guild).base_url(), await Pterodactyl.config.guild(interaction.guild).api_key(), await Pterodactyl.config.guild(interaction.guild).server_id()] - message = "" - if self.base_url.value != "": - config_list[0].set(self.base_url) - message += f"Base URL set to `{self.base_url.value}`.\n" - if self.api_key.value != "": - config_list[1].set(self.api_key) - message += f"API Key set to `{self.api_key.value}`.\n" - if self.server_id.value != "": - config_list[2].set(self.server_id) - message += f"Server ID set to `{self.server_id.value}`.\n" - if message == "": - message = f"No changes were made.\nCurrent configuration:\n- Base URL: `{config_list[0]}`\n- API Key: `{config_list[1]}`\n- Server ID: `{config_list[2]}`" - await interaction.response.send_message(message, ephemeral=True) + async def on_submit(self, interaction: discord.Interaction): + config_list = [await Pterodactyl.config.guild(self.guild).base_url(), await Pterodactyl.config.guild(self.guild).api_key(), await Pterodactyl.config.guild(self.guild).server_id()] + message = "" + if self.base_url.value != "": + config_list[0].set(self.base_url) + message += f"Base URL set to `{self.base_url.value}`.\n" + if self.api_key.value != "": + config_list[1].set(self.api_key) + message += f"API Key set to `{self.api_key.value}`.\n" + if self.server_id.value != "": + config_list[2].set(self.server_id) + message += f"Server ID set to `{self.server_id.value}`.\n" + if message == "": + message = f"No changes were made.\nCurrent configuration:\n- Base URL: `{config_list[0]}`\n- API Key: `{config_list[1]}`\n- Server ID: `{config_list[2]}`" + await interaction.response.send_message(message, ephemeral=True)