Skip to content

Commit

Permalink
cleaned up logging to info and minutes to seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
99oblivius committed Sep 20, 2024
1 parent 729aa70 commit cb23e92
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/cogs/matches/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async def shuffle_map_pool(self, interaction: nextcord.Interaction):
shuffled_maps = await self.bot.store.get_maps(guild_id=interaction.guild.id)
map_list = [m.map for m in shuffled_maps]

log.debug(f"{interaction.user.display_name} shuffled the map pool:")
log.info(f"{interaction.user.display_name} shuffled the map pool:")

await interaction.followup.send(
f"Maps have been successfully shuffled. New order:\n`{', '.join(map_list)}`", ephemeral=True)
Expand All @@ -221,8 +221,7 @@ async def shuffle_map_pool(self, interaction: nextcord.Interaction):
async def set_mm_accept_period(self, interaction: nextcord.Interaction,
seconds: int=nextcord.SlashOption(min_value=0, max_value=1800)):
await self.bot.store.upsert(BotSettings, guild_id=interaction.guild.id, mm_accept_period=seconds)
log.debug(f"{interaction.user.display_name} set the accept period to:")
log.pretty(seconds)
log.info(f"{interaction.user.display_name} set the accept period to: {seconds}")
await interaction.response.send_message(f"Accept period set to `{format_duration(seconds)}`", ephemeral=True)

settings: BotSettings = await self.bot.store.get_settings(interaction.guild.id)
Expand All @@ -238,20 +237,20 @@ async def autocomplete_accept_period(self, interaction: nextcord.Interaction, se
@mm_settings.subcommand(name="join_period", description="Set match join period")
async def set_mm_join_period(self, interaction: nextcord.Interaction,
minutes: int=nextcord.SlashOption(min_value=0, max_value=30)):
await self.bot.store.upsert(BotSettings, guild_id=interaction.guild.id, mm_join_period=minutes * 60)
log.debug(f"{interaction.user.display_name} set the join period to:")
log.pretty(minutes)
await interaction.response.send_message(f"Join period set to `{format_duration(minutes * 60)}`", ephemeral=True)
seconds = minutes * 60
await self.bot.store.upsert(BotSettings, guild_id=interaction.guild.id, mm_join_period=seconds)
log.info(f"{interaction.user.display_name} set the join period to: {seconds}")
await interaction.response.send_message(f"Join period set to `{format_duration(seconds)}`", ephemeral=True)

settings: BotSettings = await self.bot.store.get_settings(interaction.guild.id)
await log_moderation(interaction, settings.log_channel, "Join period changed", f"{format_duration(minutes * 60)}")
await log_moderation(interaction, settings.log_channel, "Join period changed", f"{format_duration(seconds)}")

@set_mm_join_period.on_autocomplete("minutes")
async def autocomplete_join_period(self, interaction: nextcord.Interaction, minutes):
settings = await self.bot.store.get_settings(interaction.guild.id)
if not minutes or not settings.mm_queue_periods:
return await interaction.response.send_autocomplete(choices=[15])
await interaction.response.send_autocomplete(choices=[minutes, (settings.mm_join_period / 60)])
await interaction.response.send_autocomplete(choices=[minutes, int(settings.mm_join_period / 60)])

@mm_settings.subcommand(name="map_options", description="Set how many maps are revealed for pick and bans")
async def set_maps_range(self, interaction: nextcord.Interaction, size: int=nextcord.SlashOption(min_value=3, max_value=10)):
Expand All @@ -274,7 +273,7 @@ async def set_map_pool(self, interaction: nextcord.Interaction,
settings = await self.bot.store.get_settings(interaction.guild.id)
await self.bot.store.upsert(BotSettings, guild_id=interaction.guild.id, mm_maps_range=min(settings.mm_maps_range, len(m)), mm_maps_phase=0)
await self.bot.store.set_maps(guild_id=interaction.guild.id, maps=[(k, v) for k, v in m.items()])
log.debug(f"{interaction.user.display_name} set the map pool to:")
log.info(f"{interaction.user.display_name} set the map pool to:")
log.pretty(m)
await interaction.response.send_message(
f"Maps successfully set to `{', '.join([k for k in m.keys()])}`", ephemeral=True)
Expand Down Expand Up @@ -309,7 +308,7 @@ async def set_mods(self, interaction: nextcord.Interaction,
"The file you provided did not contain a valid json string\ne.g. `{\"RconPlus\": \"UGC3462586\",}`", ephemeral=True)

await self.bot.store.set_mods(guild_id=interaction.guild.id, mods=[(k, v) for k, v in m.items()])
log.debug(f"{interaction.user.display_name} set the mods to:")
log.info(f"{interaction.user.display_name} set the mods to:")
log.pretty(m)
await interaction.response.send_message(
f"Mods successfully set to `{', '.join([k for k in m.keys()])}`", ephemeral=True)
Expand Down

0 comments on commit cb23e92

Please sign in to comment.