Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a280696ca | ||
|
|
8825afdb46 | ||
|
|
6fc91e0708 | ||
|
|
95cfcca600 | ||
|
|
0419c9dfd6 |
+1
-1
@@ -14,6 +14,6 @@ COPY classes classes/
|
|||||||
COPY cogs cogs/
|
COPY cogs cogs/
|
||||||
COPY database_setup database_setup/
|
COPY database_setup database_setup/
|
||||||
|
|
||||||
RUN pip install --upgrade pip && pip install poetry && poetry export -f requirements.txt --output requirements.txt && pip install -r requirements.txt
|
RUN pip install --upgrade pip && pip install poetry==1.8.3 && poetry export -f requirements.txt --output requirements.txt && pip install -r requirements.txt
|
||||||
|
|
||||||
CMD ["python3", "-u", "./main.py"]
|
CMD ["python3", "-u", "./main.py"]
|
||||||
+1
-1
@@ -200,7 +200,7 @@ class Election:
|
|||||||
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
|
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
|
||||||
await election_thread.send(message)
|
await election_thread.send(message)
|
||||||
vote_msg = await election_thread.send(
|
vote_msg = await election_thread.send(
|
||||||
build_votes_str(settings, self.guild),
|
build_votes_str(self.guild),
|
||||||
view=VoteView(self.guild),
|
view=VoteView(self.guild),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class VoteSelect(nextcord.ui.StringSelect):
|
|||||||
session.execute(stmt)
|
session.execute(stmt)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
vote_message_str = build_votes_str(settings, interaction.guild)
|
vote_message_str = build_votes_str(interaction.guild)
|
||||||
vote_msg: nextcord.Message = await interaction.channel.fetch_message(vote_msg_id)
|
vote_msg: nextcord.Message = await interaction.channel.fetch_message(vote_msg_id)
|
||||||
await vote_msg.edit(content=vote_message_str)
|
await vote_msg.edit(content=vote_message_str)
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class EventView(nextcord.ui.View):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name: str, host_id: int):
|
def __init__(self, name: str, host_id: int):
|
||||||
super().__init__()
|
super().__init__(timeout=60 * 60 * 2) # timeout 2 hours
|
||||||
|
|
||||||
self.name: str = name
|
self.name: str = name
|
||||||
self.host_id: int = host_id
|
self.host_id: int = host_id
|
||||||
|
|||||||
+24
-5
@@ -215,6 +215,7 @@ class ViewCog(commands.Cog, name="View Commands"):
|
|||||||
await interaction.response.send_autocomplete(autofilled_elections[:25])
|
await interaction.response.send_autocomplete(autofilled_elections[:25])
|
||||||
|
|
||||||
@event_points.on_autocomplete("quarter_name")
|
@event_points.on_autocomplete("quarter_name")
|
||||||
|
@clan_points.on_autocomplete("quarter_name")
|
||||||
async def event_points_autocomplete(self, interaction: nextcord.Interaction, quarter_name: str) -> None:
|
async def event_points_autocomplete(self, interaction: nextcord.Interaction, quarter_name: str) -> None:
|
||||||
"""
|
"""
|
||||||
Collects all elections that start with the election string.
|
Collects all elections that start with the election string.
|
||||||
@@ -263,16 +264,34 @@ def create_points_string(interaction: nextcord.Interaction, quarters: any, point
|
|||||||
sorted_non_members = None
|
sorted_non_members = None
|
||||||
sorted_members = members.sort_values(
|
sorted_members = members.sort_values(
|
||||||
by="UserId",
|
by="UserId",
|
||||||
key=lambda user_ids: (
|
key=lambda user_ids: ([member_lambda_string(interaction.guild, user_id) for user_id in user_ids]),
|
||||||
[interaction.guild.get_member(int(user_id)).display_name.lower() for user_id in user_ids]
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
sorted_all = pd.concat([sorted_members, sorted_non_members], ignore_index=True, sort=False)
|
sorted_all = pd.concat([sorted_members, sorted_non_members], ignore_index=True, sort=False)
|
||||||
for row in sorted_all.itertuples():
|
for row in sorted_all.itertuples():
|
||||||
userid = row.UserId
|
|
||||||
points = row.EventPoints if point_type == PointType.EVENT else row.ClanPoints
|
points = row.EventPoints if point_type == PointType.EVENT else row.ClanPoints
|
||||||
discord_member = row.DiscordMember
|
discord_member = row.DiscordMember
|
||||||
if points > 0:
|
if points > 0:
|
||||||
content += f"<@{userid}>: {points}\n" if discord_member else f"{userid}: {points}\n"
|
content += f"<@{row.UserId}>: {points}\n" if discord_member else f"{row.UserId}: {points}\n"
|
||||||
content += "\n"
|
content += "\n"
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
def member_lambda_string(guild: nextcord.Guild, user_id: int) -> str:
|
||||||
|
"""
|
||||||
|
Finds a user in a guild and returns the display name.
|
||||||
|
|
||||||
|
Returns the user id in string form if user is no longer in guild.
|
||||||
|
I don't know if I like this name very much.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
guild (nextcord.Guild): Guild object to find the user in.
|
||||||
|
user_id (int): User id to get display name of.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: String to use for sorting.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return guild.get_member(int(user_id)).display_name.lower()
|
||||||
|
except AttributeError:
|
||||||
|
# The user is no longer a part of the guild
|
||||||
|
return str(user_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user