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
+5 -15
View File
@@ -32,9 +32,7 @@ class RemoveCog(commands.Cog, name="Remove Commands"):
async def presence(
self,
interaction: nextcord.Interaction,
presence_str: str = nextcord.SlashOption(
description="The presence to remove", required=True
),
presence_str: str = nextcord.SlashOption(description="The presence to remove", required=True),
):
"""
Deletes the given presence id from the database.
@@ -53,9 +51,7 @@ class RemoveCog(commands.Cog, name="Remove Commands"):
await interaction.response.send_message("Presence deleted.", ephemeral=True)
@presence.on_autocomplete("presence_str")
async def presence_autocomplete(
self, interaction: nextcord.Interaction, presence_str: str
):
async def presence_autocomplete(self, interaction: nextcord.Interaction, presence_str: str):
"""
Collects all presences that start with the presence string.
Sends autocomplete dict {Presence Name, Presence Id}
@@ -67,20 +63,14 @@ class RemoveCog(commands.Cog, name="Remove Commands"):
with Session(engine) as session:
stmt = select(Presences)
presences_dict: "dict[str,str]" = {
pres.Presence: str(pres.Id) for pres in session.scalars(stmt)
}
presences_dict: "dict[str,str]" = {pres.Presence: str(pres.Id) for pres in session.scalars(stmt)}
# if empty compare string
if not presence_str:
await interaction.response.send_autocomplete(
dict(list(presences_dict.items())[:25])
)
await interaction.response.send_autocomplete(dict(list(presences_dict.items())[:25]))
return
autofilled_presences: "dict[str,str]" = {
pres: pres_id
for pres, pres_id in presences_dict.items()
if presence_str.lower() in pres.lower()
pres: pres_id for pres, pres_id in presences_dict.items() if presence_str.lower() in pres.lower()
}
await interaction.response.send_autocomplete(autofilled_presences[:25])