Skip to content

Commit d3cccda

Browse files
committed
Stability fixes
1 parent 4296a88 commit d3cccda

File tree

17 files changed

+54
-27
lines changed

17 files changed

+54
-27
lines changed

extensions/mizedit/MODIFY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ If we now look at CVN_73 for instance, this will be the result:
111111
```
112112

113113
> [!NOTE]
114-
> Besides "replace", you can also use:
114+
> Besides "replace" you can also use:
115115
> - delete: delete something from your mission, a unit type for instance, random failures, a whole coalition, etc.
116116
> - merge: merge two parts of your mission file, like blue and neutral countries to create a new blue.
117117

plugins/admin/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ async def on_message(self, message: discord.Message):
13691369
else:
13701370
await message.channel.send(
13711371
_('To apply the new config by restarting a node or the whole cluster, use {}').format(
1372-
(await utils.get_command(self.bot, group='node', name='restart')).mention
1372+
(await utils.get_command(self.bot, group=self.node_group.name, name=self.restart.name)).mention
13731373
)
13741374
)
13751375

plugins/cloud/commands.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ async def cloud_sync(self):
375375
self.log.warning(f"Could not replicate user {row[0]}: {ex}")
376376
await cursor.execute('UPDATE players SET synced = TRUE WHERE ucid = %s', (row[0], ))
377377

378+
@cloud_sync.before_loop
379+
async def before_cloud_sync(self):
380+
await self.bot.wait_until_ready()
381+
382+
378383
@tasks.loop(hours=1)
379384
async def register(self):
380385
async with self.apool.connection() as conn:

plugins/creditsystem/listener.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ async def addSquadronPoints(self, server: Server, data: dict) -> None:
102102
squadron = self.squadrons.get(data['squadron'])
103103
if not squadron:
104104
campaign_id, name = utils.get_running_campaign(self.node, server)
105+
if not campaign_id:
106+
self.log.warning("You need an active campaign to use squadron credits!")
107+
return
105108
squadron = DataObjectFactory().new(Squadron, node=self.node, name=data['squadron'],
106109
campaign_id=campaign_id)
107110
self.squadrons[data['squadron']] = squadron

plugins/creditsystem/player.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def __post_init__(self):
2828
if cursor.rowcount == 1:
2929
row = cursor.fetchone()
3030
campaign_id, _ = utils.get_running_campaign(self.node, self.server)
31+
if not campaign_id:
32+
self.squadron = None
33+
return
3134
self.squadron = DataObjectFactory().new(Squadron, node=self.node, name=row[0], campaign_id=campaign_id)
3235
else:
3336
self.squadron = None

plugins/gamemaster/listener.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ async def onChatMessage(self, server: Server, data: dict) -> None:
8989
))
9090

9191
async def get_coalition(self, server: Server, player: Player) -> Coalition | None:
92+
if not server.locals.get('coalitions'):
93+
return None
9294
if not player.coalition:
9395
lock_time = server.locals['coalitions'].get('lock_time', '1 day')
9496
async with self.apool.connection() as conn:

plugins/gamemaster/upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ async def post_upload(self, uploaded: list[discord.Attachment]):
6363
if num > 0:
6464
await self.channel.send(
6565
_("{num} LUA files uploaded. You can load any of them with {command} now.").format(
66-
num=num, command=(await utils.get_command(self.bot, name='do_script_file')).mention
66+
num=num, command=(await utils.get_command(self.bot, name=self.plugin.do_script_file.name)).mention
6767
)
6868
)

plugins/greenieboard/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ async def add(self, interaction: discord.Interaction,
241241
# noinspection PyUnresolvedReferences
242242
await interaction.response.send_message(
243243
_('You need to specify grades in your greenieboard.yaml to use {}!').format(
244-
(await utils.get_command(self.bot, group='traps', name='add')).mention
244+
(await utils.get_command(self.bot, group=self.traps.name, name=self.add.name)).mention
245245
), ephemeral=True)
246246
return
247247

plugins/mission/commands.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ async def _restart(self, interaction: discord.Interaction,
395395
_("Timeout while the mission {what}.\n"
396396
"Please check with {command}, if the mission is running.").format(
397397
what=_(actions.get(what)),
398-
command=(await utils.get_command(self.bot, group='mission', name='info')).mention
398+
command=(await utils.get_command(self.bot, group=self.mission.name, name=self.info.name)).mention
399399
), ephemeral=ephemeral)
400400

401401
async def _load(self, interaction: discord.Interaction, server: Server, mission: int | str | None = None,
@@ -488,7 +488,7 @@ async def _load(self, interaction: discord.Interaction, server: Server, mission:
488488
message += _('\nThis mission is NOT in the mission list and will not auto-load on server '
489489
'or mission restarts.\n'
490490
'If you want it to auto-load, use {}').format(
491-
(await utils.get_command(self.bot, group='mission', name='add')).mention)
491+
(await utils.get_command(self.bot, group=self.mission.name, name=self.add.name)).mention)
492492
await msg.edit(content=message)
493493
await self.bot.audit(f"loaded mission {utils.escape_string(name)}", server=server,
494494
user=interaction.user)
@@ -1336,21 +1336,26 @@ async def screenshot(self, interaction: discord.Interaction,
13361336

13371337
watch = Group(name="watch", description="Commands to manage the watchlist")
13381338

1339-
@watch.command(description=_('Puts a player onto the watchlist'))
1339+
@watch.command(name='add', description=_('Puts a player onto the watchlist'))
13401340
@app_commands.guild_only()
13411341
@utils.app_has_role('DCS Admin')
1342-
async def add(self, interaction: discord.Interaction,
1343-
user: app_commands.Transform[discord.Member | str, utils.UserTransformer(
1344-
sel_type=PlayerType.PLAYER, watchlist=False)], reason: str):
1342+
async def _add(self, interaction: discord.Interaction,
1343+
user: app_commands.Transform[discord.Member | str, utils.UserTransformer(
1344+
sel_type=PlayerType.PLAYER, watchlist=False)], reason: str):
13451345
if isinstance(user, discord.Member):
13461346
ucid = await self.bot.get_ucid_by_member(user)
13471347
if not ucid:
13481348
# noinspection PyUnresolvedReferences
13491349
await interaction.response.send_message(_("Member {} is not linked!").format(user.display_name),
13501350
ephemeral=True)
13511351
return
1352-
else:
1352+
elif utils.is_ucid(user):
13531353
ucid = user
1354+
else:
1355+
# noinspection PyUnresolvedReferences
1356+
await interaction.response.send_message(_("User not found."), ephemeral=True)
1357+
return
1358+
13541359
try:
13551360
async with self.apool.connection() as conn:
13561361
async with conn.transaction():
@@ -1624,7 +1629,7 @@ async def _info(self, interaction: discord.Interaction, member: discord.Member |
16241629
# noinspection PyUnresolvedReferences
16251630
await interaction.response.send_message(
16261631
_("This user does not exist. Try {} to find them in the historic data.").format(
1627-
(await utils.get_command(self.bot, name='find')).mention
1632+
(await utils.get_command(self.bot, name=self.find.name)).mention
16281633
), ephemeral=True)
16291634
return
16301635
ephemeral = utils.get_ephemeral(interaction)

plugins/modmanager/commands.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ async def download(self, interaction: discord.Interaction, folder: Folder, url:
497497
return
498498
await msg.edit(content=_("{file} downloaded. Use {command} to install it.").format(
499499
file=f"{package_name}_v{version}",
500-
command=(await utils.get_command(self.bot, group='mods', name='install')).mention
500+
command=(await utils.get_command(self.bot, group=self.mods.name, name=self._install.name)).mention
501501
))
502502
else:
503503
filename = url.split('/')[-1]
@@ -510,7 +510,8 @@ async def download(self, interaction: discord.Interaction, folder: Folder, url:
510510
return
511511
await self.service.download_from_repo(url, folder, version=version, force=True)
512512
await msg.edit(content=_("{file} downloaded. Use {command} to install it.").format(
513-
file=filename, command=(await utils.get_command(self.bot, group='mods', name='install')).mention))
513+
file=filename, command=(await utils.get_command(self.bot, group=self.mods.name,
514+
name=self._install.name)).mention))
514515

515516

516517
async def setup(bot: DCSServerBot):

0 commit comments

Comments
 (0)