Update refresh messages command to be able to choose a channel.
build_latest / build (push) Failing after 17s
build_develop / build (push) Failing after 17s

This commit is contained in:
2024-05-16 21:45:36 -04:00
parent 04c44bc470
commit 00c8227b8e
+23 -3
View File
@@ -2,10 +2,12 @@
Contained commands and views for refresh commands. Contained commands and views for refresh commands.
""" """
import os
import nextcord import nextcord
from nextcord.ext import commands from nextcord.ext import commands
from utils import edit_clan_council_info, update_clan_messages from utils import MESSAGES_DIR, edit_clan_council_info, update_clan_messages
class RefreshCog(commands.Cog, name="Refresh Commands"): class RefreshCog(commands.Cog, name="Refresh Commands"):
@@ -29,15 +31,33 @@ class RefreshCog(commands.Cog, name="Refresh Commands"):
""" """
@refresh.subcommand(description="Force refresh all of the bot managed messages.") @refresh.subcommand(description="Force refresh all of the bot managed messages.")
async def messages(self, interaction: nextcord.Interaction): async def messages(
self,
interaction: nextcord.Interaction,
channel: nextcord.TextChannel = nextcord.SlashOption(
description="Channel to refresh messages in.",
required=False,
),
):
""" """
Calls update_clan_messages() to update all messages. Calls update_clan_messages() to update all messages.
Args: Args:
interaction (nextcord.Interaction): Interaction with the command. interaction (nextcord.Interaction): Interaction with the command.
channel (nextcord.TextChannel): channel to refresh messages in.
""" """
await interaction.response.defer(ephemeral=True) await interaction.response.defer(ephemeral=True)
await update_clan_messages(interaction.guild)
if channel is None:
channel_updates = [
dir_name
for dir_name in os.listdir(MESSAGES_DIR)
if os.path.isdir(f"{MESSAGES_DIR}/{dir_name}")
]
else:
channel_updates = [channel.name]
await update_clan_messages(interaction.guild, channel_updates)
await interaction.followup.send("Messages have been refreshed.", ephemeral=True) await interaction.followup.send("Messages have been refreshed.", ephemeral=True)
@refresh.subcommand(description="Updates the current council info message.") @refresh.subcommand(description="Updates the current council info message.")