I think I actually fixed it this time
This commit is contained in:
parent
68cbabb7df
commit
9c8f143de4
1 changed files with 6 additions and 7 deletions
|
@ -42,11 +42,10 @@ class Pterodactyl(commands.Cog):
|
||||||
@app_commands.command()
|
@app_commands.command()
|
||||||
async def config(self, interaction: discord.Interaction):
|
async def config(self, interaction: discord.Interaction):
|
||||||
"""Configures the Pterodactyl cog."""
|
"""Configures the Pterodactyl cog."""
|
||||||
config_list = [await self.config.guild(interaction.guild).base_url(), await self.config.guild(interaction.guild).api_key(), await self.config.guild(interaction.guild).server_id()]
|
await interaction.response.send_modal(self.ConfigModal(self.config))
|
||||||
await interaction.response.send_modal(self.ConfigModal(config_list))
|
|
||||||
|
|
||||||
class ConfigModal(discord.ui.Modal, title="Pterodactyl Manager Configuration"):
|
class ConfigModal(discord.ui.Modal, title="Pterodactyl Manager Configuration"):
|
||||||
def __init__(self, config: list):
|
def __init__(self, config):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.config = config
|
self.config = config
|
||||||
base_url = discord.ui.TextInput(
|
base_url = discord.ui.TextInput(
|
||||||
|
@ -74,14 +73,14 @@ class Pterodactyl(commands.Cog):
|
||||||
async def on_submit(self, interaction: discord.Interaction):
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
message = ""
|
message = ""
|
||||||
if self.base_url.value != "":
|
if self.base_url.value != "":
|
||||||
self.config[0].set(self.base_url)
|
self.config.guild(interaction.guild).base_url.set(self.base_url)
|
||||||
message += f"Base URL set to `{self.base_url.value}`.\n"
|
message += f"Base URL set to `{self.base_url.value}`.\n"
|
||||||
if self.api_key.value != "":
|
if self.api_key.value != "":
|
||||||
self.config[1].set(self.api_key)
|
self.config.guild(interaction.guild).api_key.set(self.api_key)
|
||||||
message += f"API Key set to `{self.api_key.value}`.\n"
|
message += f"API Key set to `{self.api_key.value}`.\n"
|
||||||
if self.server_id.value != "":
|
if self.server_id.value != "":
|
||||||
self.config[2].set(self.server_id)
|
self.config.guild(interaction.guild).server_id.set(self.server_id)
|
||||||
message += f"Server ID set to `{self.server_id.value}`.\n"
|
message += f"Server ID set to `{self.server_id.value}`.\n"
|
||||||
if message == "":
|
if message == "":
|
||||||
message = f"No changes were made.\nCurrent configuration:\n- Base URL: `{self.config[0]}`\n- API Key: `{self.config[1]}`\n- Server ID: `{self.config[2]}`"
|
message = f"No changes were made.\nCurrent configuration:\n- Base URL: `{self.config.guild(interaction.guild).base_url()}`\n- API Key: `{self.config.guild(interaction.guild).api_key()}`\n- Server ID: `{self.config.guild(interaction.guild).server_id()}`"
|
||||||
await interaction.response.send_message(message, ephemeral=True)
|
await interaction.response.send_message(message, ephemeral=True)
|
||||||
|
|
Reference in a new issue