Add autofill to get all users in guild.
This commit is contained in:
@@ -137,6 +137,32 @@ def autofill_users_in_group_category(
|
||||
return users
|
||||
|
||||
|
||||
def autofill_users_in_guild(guild_id: int, user_begin: str) -> "list[str]":
|
||||
"""
|
||||
Obtains and returns a list of all the users who have submitted to the guild's highscores.
|
||||
|
||||
Args:
|
||||
guild_id (int): Id of the guild.
|
||||
user_begin (str): Beginning of user name to search with. Can be empty.
|
||||
|
||||
Returns:
|
||||
list[str]: All users with submissions in the guild.
|
||||
"""
|
||||
group_ids = select(CategoryGroup.GroupId).where(CategoryGroup.GuildId == guild_id).subquery()
|
||||
category_ids = select(Category.CategoryId).where(Category.GroupId.in_(group_ids)).subquery()
|
||||
stmt = select(distinct(Score.UserName)).where(Score.CategoryId.in_(category_ids))
|
||||
users_list: "list[str]" = list(session.scalars(stmt))
|
||||
|
||||
# if string empty, return all users
|
||||
if not user_begin:
|
||||
return users_list
|
||||
|
||||
# else find all users that start with user_begin
|
||||
users = [user for user in users_list if user_begin.lower() in user.lower()]
|
||||
|
||||
return users
|
||||
|
||||
|
||||
def format_highscore_message(group: CategoryGroup) -> str:
|
||||
"""
|
||||
Creates a formatted string for a boss's highscore discord message.
|
||||
|
||||
Reference in New Issue
Block a user