|
|
@@ -9,39 +9,41 @@ class civsitu(commands.Cog):
|
|
|
def __init__(self, bot: discord.Bot):
|
|
|
self.bot = bot
|
|
|
|
|
|
- def _load_config(self):
|
|
|
- config = configparser.ConfigParser()
|
|
|
- configFilePath = r'config.cfg'
|
|
|
- config.read(configFilePath)
|
|
|
- return config
|
|
|
- def _get_situ_channel(self):
|
|
|
- config = self._load_config()
|
|
|
- situ_channel_id = int(config["Civ"]["situ_channel_id"])
|
|
|
- situ_channel = self.bot.get_channel(situ_channel_id)
|
|
|
- if situ_channel is None:
|
|
|
- print(f"Log channel with ID {situ_channel_id} not found.")
|
|
|
- return None
|
|
|
- return situ_channel
|
|
|
- """def _get_situ_team_channel(self):
|
|
|
- config = self._load_config()
|
|
|
- situ_team_channel_id = int(config["Civ"]["situ_team_channel_id"])
|
|
|
- situ_team_channel = self.bot.get_channel(situ_team_channel_id)
|
|
|
- if situ_team_channel is None:
|
|
|
- print(f"Log channel with ID {situ_team_channel_id} not found.")
|
|
|
- return None
|
|
|
- return situ_team_channel"""
|
|
|
-
|
|
|
- #situ_team_channel = self._get_situ_team_channel()
|
|
|
-
|
|
|
#Modal form
|
|
|
class Situ(discord.ui.Modal):
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
super().__init__(*args, **kwargs)
|
|
|
+
|
|
|
+ #Modal form layout
|
|
|
self.add_item(discord.ui.InputText(label="Teilnehmende Spieler", placeholder="Gib die Namen der teilnehmenden Spieler abgesehen von dir ein.", required=False, ))
|
|
|
self.add_item(discord.ui.InputText(label="Benötigte Ausrüstung", placeholder="Gib die benötigte Ausrüstung an (Drogen, Waffen, etc.)."))
|
|
|
self.add_item(discord.ui.InputText(label="Situationsbeschreibung", style=discord.InputTextStyle.long, placeholder="Beschreibe die Situation so detailliert wie möglich (Was? Wo? Wie?)."))
|
|
|
self.add_item(discord.ui.InputText(label="Besonderheiten", placeholder="Langzeitsituationen, besondere Umstände, etc.", required=False))
|
|
|
|
|
|
+ #funktions to load the config and get the channels
|
|
|
+ def _load_config(self):
|
|
|
+ config = configparser.ConfigParser()
|
|
|
+ configFilePath = r'config.cfg'
|
|
|
+ config.read(configFilePath)
|
|
|
+ return config
|
|
|
+ def _get_situ_channel(self):
|
|
|
+ config = self._load_config()
|
|
|
+ situ_channel_id = int(config["Civ"]["situ_channel_id"])
|
|
|
+ situ_channel = self.bot.get_channel(situ_channel_id)
|
|
|
+ if situ_channel is None:
|
|
|
+ print(f"Log channel with ID {situ_channel_id} not found.")
|
|
|
+ return None
|
|
|
+ return situ_channel
|
|
|
+ """def _get_situ_team_channel(self):
|
|
|
+ config = self._load_config()
|
|
|
+ situ_team_channel_id = int(config["Civ"]["situ_team_channel_id"])
|
|
|
+ situ_team_channel = self.bot.get_channel(situ_team_channel_id)
|
|
|
+ if situ_team_channel is None:
|
|
|
+ print(f"Log channel with ID {situ_team_channel_id} not found.")
|
|
|
+ return None
|
|
|
+ return situ_team_channel"""
|
|
|
+
|
|
|
+
|
|
|
#Output of the Modal form
|
|
|
async def callback(self, interaction: discord.Interaction):
|
|
|
#Public embed with less information
|
|
|
@@ -50,12 +52,15 @@ class civsitu(commands.Cog):
|
|
|
embed_pub.add_field(name="Teilnehmer", value=self.children[0].value, inline=False)
|
|
|
embed_pub.add_field(name="Long Input", value=self.children[1].value, inline=False)
|
|
|
self.embed_pub = embed_pub
|
|
|
+
|
|
|
+ #sending the embed
|
|
|
await interaction.response.send_message("Die Situation wurde erfolgreich erstellt und veröffentlicht.", ephemeral=True)
|
|
|
- situ_channel = civsitu._get_situ_channel(self)
|
|
|
+ situ_channel = self._get_situ_channel()
|
|
|
msg = await situ_channel.send(embeds=[embed_pub])
|
|
|
name = f"situation-{interaction.user.name}"
|
|
|
thread =await msg.create_thread(name=name, auto_archive_duration=1440)
|
|
|
|
|
|
+
|
|
|
#embed with more information sent into a thread attached to the public embed
|
|
|
embed_team = discord.Embed(title="Aktive Situation")
|
|
|
embed_team.add_field(name="Ersteller", value=interaction.user.mention, inline=False)
|
|
|
@@ -63,6 +68,7 @@ class civsitu(commands.Cog):
|
|
|
embed_team.add_field(name="Benötigte Ausrüstung", value=self.children[1].value, inline=False)
|
|
|
embed_team.add_field(name="Situationsbeschreibung", value=self.children[2].value, inline=False)
|
|
|
embed_team.add_field(name="Besonderheiten", value=self.children[3].value, inline=False)
|
|
|
+
|
|
|
self.embed_team = embed_team
|
|
|
await thread.send(embeds=[embed_team])
|
|
|
await thread.send("Please wait with the start of your situation unil a (civ-) team member approved your situation.")
|
|
|
@@ -72,7 +78,6 @@ class civsitu(commands.Cog):
|
|
|
@slash_command()
|
|
|
async def civsitu(self, ctx: discord.ApplicationContext):
|
|
|
"""Start a new civ-RP situation."""
|
|
|
- situ_channel = self._get_situ_channel()
|
|
|
modal = self.Situ(title="Create a new civ-rp situation") # type: ignore
|
|
|
await ctx.send_modal(modal)
|
|
|
|