Turned on all ruff rules. Formatted all files.

This commit is contained in:
2024-05-22 15:06:39 -04:00
parent 3ac164ab65
commit 796b052bfc
18 changed files with 161 additions and 469 deletions
+12 -37
View File
@@ -32,9 +32,7 @@ class RecordCog(commands.Cog, name="Record Commands"):
async def event(
self,
interaction: nextcord.Interaction,
name: str = nextcord.SlashOption(
required=True, description="Name of the event that was hosted."
),
name: str = nextcord.SlashOption(required=True, description="Name of the event that was hosted."),
host: nextcord.Member = nextcord.SlashOption(
required=False,
description="An alternative host if you are recording event for someone else.",
@@ -51,10 +49,7 @@ class RecordCog(commands.Cog, name="Record Commands"):
"""
# check role
if (
interaction.guild.get_role(self.bot.config.params.event_host_role_id)
not in interaction.user.roles
):
if interaction.guild.get_role(self.bot.config.params.event_host_role_id) not in interaction.user.roles:
await interaction.response.send_message(
f"You must have the <@&{self.bot.config.params.event_host_role_id}> role to record an event.",
ephemeral=True,
@@ -95,15 +90,11 @@ class EventView(nextcord.ui.View):
self.add_item(self.event_participants)
@nextcord.ui.button(label="Cancel", style=nextcord.ButtonStyle.red, row=1)
async def cancel(
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
):
async def cancel(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
"""
Cancels event submission. Removes embed and view.
"""
await interaction.response.edit_message(
"Canceled", ephemeral=True, embed=None, view=None
)
await interaction.response.edit_message("Canceled", ephemeral=True, embed=None, view=None)
self.stop()
@nextcord.ui.button(label="Edit", style=nextcord.ButtonStyle.blurple, row=1)
@@ -111,14 +102,10 @@ class EventView(nextcord.ui.View):
"""
Calls modal to update the text input information of the event.
"""
await interaction.response.send_modal(
ParticipantModal(interaction.message.embeds[0])
)
await interaction.response.send_modal(ParticipantModal(interaction.message.embeds[0]))
@nextcord.ui.button(label="Confirm", style=nextcord.ButtonStyle.green, row=1)
async def confirm(
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
):
async def confirm(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
"""
Submits the event embed to the event channel. Removes view and embed from recording message.
Sends point information to database.
@@ -126,9 +113,7 @@ class EventView(nextcord.ui.View):
discord_users = self.event_participants.values.members
if discord_users:
discord_users_list: list[str] = [
str(user.id) for user in discord_users if user.id is not self.host_id
]
discord_users_list: list[str] = [str(user.id) for user in discord_users if user.id is not self.host_id]
record_event_points(
self.config,
discord_users_list,
@@ -146,17 +131,11 @@ class EventView(nextcord.ui.View):
self.config.params.event_participate_points,
)
record_event_points(
self.config, [self.host_id], True, self.config.params.event_host_points
)
record_event_points(self.config, [self.host_id], True, self.config.params.event_host_points)
event_channel: nextcord.TextChannel = interaction.guild.get_channel(
self.config.params.event_post_channel_id
)
event_channel: nextcord.TextChannel = interaction.guild.get_channel(self.config.params.event_post_channel_id)
await event_channel.send(embed=interaction.message.embeds[0])
await interaction.response.edit_message(
content="Event has been submitted.", view=None, embed=None
)
await interaction.response.edit_message(content="Event has been submitted.", view=None, embed=None)
self.stop()
@@ -201,9 +180,7 @@ class ParticipantModal(nextcord.ui.Modal):
async def callback(self, interaction: nextcord.Interaction):
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
)
self.embed.set_field_at(index=1, name="Non-Discord Participants", value=self.participants.value)
await interaction.response.edit_message(embed=self.embed)
@@ -223,8 +200,6 @@ class ParticipantSelect(nextcord.ui.UserSelect):
async def callback(self, interaction: nextcord.Interaction):
embed: nextcord.Embed = interaction.message.embeds[0]
participants: str = "\n".join(
[f"<@{participant.id}>" for participant in self.values.members]
)
participants: str = "\n".join([f"<@{participant.id}>" for participant in self.values.members])
embed.set_field_at(0, name="Participants", value=participants)
await interaction.response.edit_message(embed=embed)