Change variable name

This commit is contained in:
Choco
2025-07-03 16:11:01 +08:00
parent 7c5caa8d6d
commit c7d19b9383
2 changed files with 11 additions and 11 deletions

View File

@@ -197,39 +197,39 @@ class Placeholders:
text = re.sub(r'@@(.*?)@@', lambda x: str(variables.get(x.group(1), '')), text)
return text
def build_embed(raw: dict[str, dict], placeholder: Placeholders) -> Embed:
def build_embed(embed_form: dict[str, dict], placeholder: Placeholders) -> Embed:
embed = Embed()
try:
rv = {key: func() if callable(func) else func for key, func in placeholder.variables.items()}
if author := raw.get("author"):
if author := embed_form.get("author"):
embed.set_author(
name = placeholder.replace(author.get("name"), rv),
url = placeholder.replace(author.get("url"), rv),
icon_url = placeholder.replace(author.get("icon_url"), rv)
)
if title := raw.get("title"):
if title := embed_form.get("title"):
embed.title = placeholder.replace(title.get("name"), rv)
embed.url = placeholder.replace(title.get("url"), rv)
if fields := raw.get("fields", []):
if fields := embed_form.get("fields", []):
for f in fields:
embed.add_field(name=placeholder.replace(f.get("name"), rv), value=placeholder.replace(f.get("value", ""), rv), inline=f.get("inline", False))
if footer := raw.get("footer"):
if footer := embed_form.get("footer"):
embed.set_footer(
text = placeholder.replace(footer.get("text"), rv),
icon_url = placeholder.replace(footer.get("icon_url"), rv)
)
if thumbnail := raw.get("thumbnail"):
if thumbnail := embed_form.get("thumbnail"):
embed.set_thumbnail(url = placeholder.replace(thumbnail, rv))
if image := raw.get("image"):
if image := embed_form.get("image"):
embed.set_image(url = placeholder.replace(image, rv))
embed.description = placeholder.replace(raw.get("description"), rv)
embed.color = int(placeholder.replace(raw.get("color"), rv))
embed.description = placeholder.replace(embed_form.get("description"), rv)
embed.color = int(placeholder.replace(embed_form.get("color"), rv))
except:
pass

View File

@@ -302,9 +302,9 @@ class Player(VoiceProtocol):
def build_embed(self, current_track: Track = None):
"""Builds an embed based on the current track state."""
controller = self.settings.get("default_controller", func.settings.controller).get("embeds", {})
raw = controller.get("active" if current_track else "inactive", {})
embed_form = controller.get("active" if current_track else "inactive", {})
return build_embed(raw, self._ph)
return build_embed(embed_form, self._ph)
async def send(self, method: RequestMethod, query: str = None, data: Union[Dict, str] = {}) -> Dict:
"""Sends an HTTP request to the node with the given method, query, and data."""