Skip to content

Commit

Permalink
Update large.py
Browse files Browse the repository at this point in the history
- Fixed an issue where player lists could exceed 1024 characters
  • Loading branch information
BattlefieldDuck committed Oct 31, 2023
1 parent 2d644ed commit a43739d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions discordgsm/styles/large.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ def add_player_list_fields(self, embed: Embed, field_name: str, players: List[Ga

# Replace Markdown
# https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-
name = name.replace('*', '\\*').replace('_', '\\_').replace('~',
'\\~').replace('`', '\\`').replace('>', '\\>')
name = name.replace('*', '\\*').replace('_', '\\_').replace('~', '\\~')
name = name.replace('`', '\\`').replace('>', '\\>') + '\n'

index = i % len(values)
counts[index] += len(name)

player_left = len(filtered_players) - player_count
remaining_players_message = f'... {player_left} more player{"" if player_left <= 1 else "s"}'

# Embed must be 1024 or fewer in length. (Actually 1000)
if (counts[index] + len(remaining_players_message)) >= 1000:
# Embed must be 1024 or fewer in length.
if (counts[index] + len(remaining_players_message)) >= 1024:
values[index] += remaining_players_message
break

values[index] += f'{name}\n'
values[index] += name
player_count += 1

for i, name in enumerate([field_name, empty_value, empty_value]):
Expand Down

0 comments on commit a43739d

Please sign in to comment.