Skip to content

Commit f4b12e8

Browse files
authored
Merge pull request #43 from Frigondin/dev
Battleground : Fixe reset command and add multiple files to recon
2 parents e1cfc33 + 061ff4a commit f4b12e8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugins/battleground2/commands.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from discord import app_commands
66
from discord.app_commands import Group
7+
from typing import Optional
78

89
from core import Plugin, utils, Channel, Coalition, Server, get_translation
910
from services.bot import DCSServerBot
@@ -24,7 +25,7 @@ async def rename(self, conn: psycopg.AsyncConnection, old_name: str, new_name: s
2425
@battleground.command(description=_('Push MGRS coordinates with screenshots to DCS Battleground'))
2526
@app_commands.guild_only()
2627
@utils.app_has_role('DCS')
27-
async def recon(self, interaction: discord.Interaction, name: str, mgrs: str, screenshot: discord.Attachment):
28+
async def recon(self, interaction: discord.Interaction, name: str, mgrs: str, screenshot1: discord.Attachment, screenshot2: Optional[discord.Attachment], screenshot3: Optional[discord.Attachment], screenshot4: Optional[discord.Attachment], screenshot5: Optional[discord.Attachment], screenshot6: Optional[discord.Attachment], screenshot7: Optional[discord.Attachment], screenshot8: Optional[discord.Attachment], screenshot9: Optional[discord.Attachment], screenshot10: Optional[discord.Attachment]):
2829
mgrs = mgrs.replace(' ', '')
2930
if len(mgrs) != 15 or not mgrs[:2].isnumeric() or not mgrs[5:].isnumeric():
3031
# noinspection PyUnresolvedReferences
@@ -43,7 +44,7 @@ async def recon(self, interaction: discord.Interaction, name: str, mgrs: str, sc
4344
else:
4445
continue
4546
done = True
46-
screenshots = [att.url for att in [screenshot]] # TODO: add multiple ones
47+
screenshots = [att.url for att in list(filter(lambda item: item is not None,[screenshot1,screenshot2,screenshot3,screenshot4,screenshot5,screenshot6,screenshot7,screenshot8,screenshot9,screenshot10]))]
4748
author = {
4849
"name": interaction.user.name,
4950
"icon_url": interaction.user.display_avatar.url
@@ -87,7 +88,7 @@ async def recon(self, interaction: discord.Interaction, name: str, mgrs: str, sc
8788
async def reset(self, interaction: discord.Interaction,
8889
server: app_commands.Transform[Server, utils.ServerTransformer]):
8990
async with self.apool.connection() as conn:
90-
async with conn.transation():
91+
async with conn.transaction():
9192
await conn.execute("DELETE FROM bg_geometry2 WHERE server_name = %s", (server.name, ))
9293
await conn.execute("DELETE FROM bg_missions WHERE server_name = %s", (server.name,))
9394
await conn.execute("DELETE FROM bg_task WHERE server_name = %s", (server.name,))

0 commit comments

Comments
 (0)