Finish up smells in the commands directory.

Add a discord max message length constant.
Move boolean argument to not be positional.
This commit is contained in:
2024-05-22 20:48:44 -04:00
parent 9331e7ba4f
commit b9621a67c9
9 changed files with 180 additions and 155 deletions
+19 -6
View File
@@ -119,11 +119,11 @@ class EventView(nextcord.ui.View):
record_event_points(
self.config,
non_discord_users_list,
False,
self.config.params.event_participate_points,
is_member=False,
)
record_event_points(self.config, [self.host_id], True, self.config.params.event_host_points)
record_event_points(self.config, [self.host_id], self.config.params.event_host_points, is_member=True)
event_channel: nextcord.TextChannel = interaction.guild.get_channel(self.config.params.event_post_channel_id)
await event_channel.send(embed=interaction.message.embeds[0])
@@ -134,12 +134,13 @@ class EventView(nextcord.ui.View):
class ParticipantModal(nextcord.ui.Modal):
"""
This modal contains all the text edits for an event. You can change the name, description, and add the usernames
of participants who are not in the discord.
This modal contains all the text edits for an event.
You can change the name, description, and add the usernames of participants who are not in the discord.
"""
# TODO turn this embed into a dict
def __init__(self, embed):
# consider turning this embed into a dict
def __init__(self, embed: nextcord.Embed):
super().__init__(
"Edit the event.",
timeout=5 * 60,
@@ -170,6 +171,12 @@ class ParticipantModal(nextcord.ui.Modal):
self.add_item(self.participants)
async def callback(self, interaction: nextcord.Interaction) -> None:
"""
Edits the interaction message to contain the Non-Discord participants.
Args:
interaction (nextcord.Interaction): Interaction of the callback.
"""
self.embed.title = self.name.value
self.embed.description = self.description.value
self.embed.set_field_at(index=1, name="Non-Discord Participants", value=self.participants.value)
@@ -189,6 +196,12 @@ class ParticipantSelect(nextcord.ui.UserSelect):
)
async def callback(self, interaction: nextcord.Interaction) -> None:
"""
Edits the interaction message to contain the Discord participants.
Args:
interaction (nextcord.Interaction): Interaction of the callback.
"""
embed: nextcord.Embed = interaction.message.embeds[0]
participants: str = "\n".join([f"<@{participant.id}>" for participant in self.values.members])
embed.set_field_at(0, name="Participants", value=participants)