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
+6 -3
View File
@@ -26,6 +26,7 @@ NOMINEE_SPLITTER = "========================================\n\n"
REPO_DIR = "./dakiny-messages"
MESSAGES_DIR = f"{REPO_DIR}/messages"
TEMPLATES_DIR = f"{REPO_DIR}/message_templates"
MAX_DISCORD_MESSAGE_LENGTH = 2000
VoteType = StrEnum("VoteType", ["COUNCIL", "DISCORDMANAGER", "CLANLEADER"])
@@ -300,7 +301,7 @@ def decorate_dm_nomination(user_id: int, speech: str) -> str:
return msg
def record_event_points(config: DakinyConfig, users: Sequence[str], is_member: bool, add_points: int) -> None: # noqa: FBT001
def record_event_points(config: DakinyConfig, users: Sequence[str], add_points: int, *, is_member: bool) -> None:
"""
Adds event points to all users listed.
@@ -310,8 +311,8 @@ def record_event_points(config: DakinyConfig, users: Sequence[str], is_member: b
Args:
config (DakinyConfig): Dakiny config for getting points
users (Sequence[int]): users that participated and need points.
is_member (bool): whether the users are a discord member or not
add_points (int): number of points to add
is_member (bool): whether the users are a discord member or not
"""
quarter_name = get_quarter_name(config)
with Session(engine) as session:
@@ -411,7 +412,9 @@ async def update_clan_messages(guild: nextcord.Guild, channel_updates: Sequence[
message_name = f"{dir_name}/{file_name}"
file_path = f"{dir_path}/{file_name}"
async with aiofiles.open(file_path, encoding="utf8") as reader:
await edit_clan_message(session, channel, message_name, await reader.read(2000))
await edit_clan_message(
session, channel, message_name, await reader.read(MAX_DISCORD_MESSAGE_LENGTH)
)
async def get_clan_message_channel(session: Session, channel_name: str, guild: nextcord.Guild) -> nextcord.TextChannel: