Closed Burner987 closed 1 week ago
If I'm not mistaken, I'm pretty sure they wanted a /erlc team [team]
command but I may be wrong
I mean this also works. Also, I forgot about DOT and Jail, so I added those in.
@server.command(
name="teams",
description="See all players in the server by the team."
)
@is_staff()
@is_server_linked()
async def server_teams(self, ctx: commands.Context):
guild_id = int(ctx.guild.id)
# status: ServerStatus = await self.bot.prc_api.get_server_status(guild_id)
players: list[Player] = await self.bot.prc_api.get_server_players(guild_id)
queue: list[Player] = await self.bot.prc_api.get_server_queue(guild_id)
embed2 = discord.Embed(
title=f"Server Players [{len(players)}]",
color=BLANK_COLOR,
description=""
)
actual_players = []
key_maps = {}
Sheriff = []
Police = []
Fire = []
DOT = []
Civ = []
Jail = []
for item in players:
if item.team == "Sheriff":
Sheriff.append(item)
elif item.team == "Police":
Police.append(item)
elif item.team == "Fire":
Fire.append(item)
elif item.team == "DOT":
DOT.append(item)
elif item.team == "Jail":
Jail.append(item)
else:
Civ.append(item)
embed2.description += (
f"**Sheriff: [{len(Sheriff)}]**\n" +
', '.join([f'[{plr.username} ({plr.permission})](https://roblox.com/users/{plr.id}/profile)' for plr in Sheriff])
)
embed2.description += (
f"\n\n**Police: [{len(Police)}]**\n" +
', '.join([f'[{plr.username} ({plr.permission})](https://roblox.com/users/{plr.id}/profile)' for plr in Police])
)
embed2.description += (
f"\n\n**Fire: [{len(Fire)}]**\n" +
', '.join([f'[{plr.username} ({plr.permission})](https://roblox.com/users/{plr.id}/profile)' for plr in Fire])
)
embed2.description += (
f"\n\n**DOT: [{len(DOT)}]**\n" +
', '.join([f'[{plr.username} ({plr.permission})](https://roblox.com/users/{plr.id}/profile)' for plr in DOT])
)
embed2.description += (
f"\n\n**Civ: [{len(Civ)}]**\n" +
', '.join([f'[{plr.username} ({plr.permission})](https://roblox.com/users/{plr.id}/profile)' for plr in Civ])
)
embed2.description += (
f"\n\n**Jail: [{len(Jail)}]**\n" +
', '.join([f'[{plr.username} ({plr.permission})](https://roblox.com/users/{plr.id}/profile)' for plr in Jail])
)
embed2.description += (
f"\n\n**Queue [{len(queue)}]**\n" +
', '.join([f'[{plr.username}](https://roblox.com/users/{plr.id}/profile)' for plr in queue])
)
embed2.set_author(
name=ctx.guild.name,
icon_url=ctx.guild.icon
)
await ctx.send(embed=embed2)
If you want to make changes to ERM, you must do so through a pull request. Additionally, initializing so many dicts like that is not performant. You should probably be processing players directly into the final string instead of storing them in intermediate lists. I also noticed that your form of string building is not ideal, strings are immutable, so each time you append to a string with +=, a new string is created. If I were you I would build a list of strings and join them once at the end.
I had made an erlc teams command, I didn't feel like making a pull request for this so I'll just add it here. I did just edit the erlc players command to make this work, so if I messed anything up, let me know. `@server.command( name="teams", description="See all players in the server by the team." ) @is_staff() @is_server_linked() async def server_teams(self, ctx: commands.Context): guild_id = int(ctx.guild.id)
status: ServerStatus = await self.bot.prc_api.get_server_status(guild_id)