Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Special emojis for bot owner and supporters in game embeds.

## [v17.1.4](https://github.com/lexicalunit/spellbot/releases/tag/v17.1.4) - 2025-11-19

### Changed
Expand Down
3 changes: 3 additions & 0 deletions src/spellbot/actions/lfg_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,13 @@ async def _handle_embed_creation(
assert self.channel

# build the game post's embed and view:
emojis = await self.bot.fetch_application_emojis()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to operations.py and make a safe_ version.

embed: discord.Embed = await self.services.games.to_embed(
guild=self.guild,
suggested_vc=suggested_vc,
rematch=rematch,
emojis=emojis,
supporters=self.bot.supporters,
)
content = self.channel_data.get("extra", None)
game_data = await self.services.games.to_dict()
Expand Down
2 changes: 2 additions & 0 deletions src/spellbot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
from contextlib import asynccontextmanager
from typing import TYPE_CHECKING
from unittest.mock import AsyncMock
from uuid import uuid4

import discord
Expand Down Expand Up @@ -202,5 +203,6 @@ def build_bot(
mock_games=mock_games,
create_connection=create_connection,
)
bot.fetch_application_emojis = AsyncMock(return_value=[])
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't need this change after moving method to operations.py.

setup_metrics()
return bot
23 changes: 20 additions & 3 deletions src/spellbot/models/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,22 @@ def apply_placeholders(self, placeholders: dict[str, str], text: str) -> str:
text = text.replace(f"${{{k}}}", v)
return text

@property
def embed_players(self) -> str:
def embed_players(
self,
emojis: list[discord.Emoji] | None = None,
supporters: set[int] | None = None,
) -> str:
emojis = emojis or []
supporters = supporters or set()

supporter_emoji = next((e for e in emojis if e.name == "spellbot"), None)
owner_emoji = next((e for e in emojis if e.name == "king"), None)

def emoji(xid: int) -> str:
if supporter_emoji and xid in supporters:
return f"{supporter_emoji} "
if owner_emoji and settings.OWNER_XID and xid == int(settings.OWNER_XID):
return f"{owner_emoji} "
return ""

player_parts: list[tuple[int, str, str]] = [
Expand Down Expand Up @@ -438,7 +451,10 @@ def to_embed(
dm: bool = False,
suggested_vc: VoiceChannelSuggestion | None = None,
rematch: bool = False,
emojis: list[discord.Emoji] | None = None,
supporters: set[int] | None = None,
) -> discord.Embed:
emojis = emojis or []
title = "**Rematch Game!**" if rematch else self.embed_title
embed = discord.Embed(title=title)
embed.set_thumbnail(url=settings.thumb(self.guild_xid))
Expand All @@ -460,7 +476,8 @@ def to_embed(
inline=False,
)
elif self.players:
embed.add_field(name="Players", value=self.embed_players, inline=False)
players_value = self.embed_players(emojis, supporters)
embed.add_field(name="Players", value=players_value, inline=False)
embed.add_field(name="Format", value=self.format_name)
if self.bracket != GameBracket.NONE.value:
embed.add_field(name="Bracket", value=self.bracket_title)
Expand Down
11 changes: 10 additions & 1 deletion src/spellbot/services/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,18 @@ def to_embed(
dm: bool = False,
suggested_vc: VoiceChannelSuggestion | None = None,
rematch: bool = False,
emojis: list[discord.Emoji] | None = None,
supporters: set[int] | None = None,
) -> discord.Embed:
assert self.game
return self.game.to_embed(guild=guild, dm=dm, suggested_vc=suggested_vc, rematch=rematch)
return self.game.to_embed(
guild=guild,
dm=dm,
suggested_vc=suggested_vc,
rematch=rematch,
emojis=emojis,
supporters=supporters,
)

@sync_to_async()
@tracer.wrap()
Expand Down
Loading