Skip to content

Commit

Permalink
Add lookup command
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed Aug 31, 2024
1 parent 4d4ffcb commit c8dffea
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/leaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,32 @@ async def assign_egn4912(
f"{team_names[file]} team: {added_successfully[file]} members added successfully. Could not find: {', '.join(could_not_find[file])}",
)

@commands.command(aliases=["yellowpages", "yp"])
@commands.has_any_role("Leaders")
async def lookup(self, ctx: commands.Context, name: str):
"""
Finds all users who could be related to by the name
"""
members: list[discord.Member] = []
for member in self.bot.active_guild.members:
if name.lower() in member.display_name.lower():
members.append(member)
if not members:
await ctx.reply("No members found.")
return
members = sorted(members, key=lambda x: x.display_name)
formatted_members = []
for member in members:
useful_roles = set(member.roles) - {self.bot.active_guild.default_role}
roles = ", ".join(role.name for role in useful_roles)
formatted_members.append(
f"* {member.display_name} ({member.mention}) - Roles: {roles}",
)
new_line_formatted = "\n".join(formatted_members)
await ctx.reply(
f"Found members: \n{new_line_formatted}",
)

def _schedule_generator(
self,
start_date: datetime.date,
Expand Down

0 comments on commit c8dffea

Please sign in to comment.