Dough Git

commit

force bot to have a style

commit
0faf2ba58c1af1b0c1c50039f90d15efe1e7e07c
author
Clove Twilight <[email protected]>
date
2026-09-29 06:51

diff --git a/sandrone/client.py b/sandrone/client.py
index 7a3cbd6..44fe581 100644
--- a/sandrone/client.py
+++ b/sandrone/client.py
@@ -14,14 +14,64 @@ from watchfiles import Change, awatch
 
 def discoverExtensions(directory: Path, package: str) -> list[str]:
     return sorted(
-        f"{package}.{path.stem}"
+        f"{package}.{path.stem}"async def applyNameStyle(self) -> None:
+        """Set her display name font/effect/colours in every server she's in.
+
+        discord.py has no wrapper for these fields yet, so they go straight
+        through the raw member-edit route. It's per-guild because bots can't
+        style their global profile.
+        """
+        fields = {
+            key: value
+            for key, value in (
+                ("display_name_font_id", config.displayNameFont),
+                ("display_name_effect_id", config.displayNameEffect),
+                ("display_name_colors", config.displayNameColors),
+            )
+            if value is not None
+        }
+        if not fields:
+            return
+
+        for guild in self.guilds:
+            try:
+                await self.http.edit_my_member(guild.id, **fields)
+            except discord.HTTPException as e:
+                print(cf.red(f"[style] couldn't style my name in {guild.id}: {e}"))
+            else:
+                print(cf.yellow(f"[style] name style set in {guild.name}"))
         for path in directory.glob("*.py")
         if path.stem != "__init__"
     )
 
 
 class Bot(commands.Bot):
-    def __init__(self, *args, **kwargs):
+    def __init__(self, *args, **kwasync def applyNameStyle(self) -> None:
+        """Set her display name font/effect/colours in every server she's in.
+
+        discord.py has no wrapper for these fields yet, so they go straight
+        through the raw member-edit route. It's per-guild because bots can't
+        style their global profile.
+        """
+        fields = {
+            key: value
+            for key, value in (
+                ("display_name_font_id", config.displayNameFont),
+                ("display_name_effect_id", config.displayNameEffect),
+                ("display_name_colors", config.displayNameColors),
+            )
+            if value is not None
+        }
+        if not fields:
+            return
+
+        for guild in self.guilds:
+            try:
+                await self.http.edit_my_member(guild.id, **fields)
+            except discord.HTTPException as e:
+                print(cf.red(f"[style] couldn't style my name in {guild.id}: {e}"))
+            else:
+                print(cf.yellow(f"[style] name style set in {guild.name}"))args):
         super().__init__(*args, **kwargs)
         self._profileSet = False
         self.startedAt = discord.utils.utcnow()
@@ -142,6 +192,27 @@ class Bot(commands.Bot):
             if reloaded:
                 await self.tree.sync()
 
+    async def applyNameStyle(self) -> None:
+        fields = {
+            key: value
+            for key, value in (
+                ("display_name_font_id", config.displayNameFont),
+                ("display_name_effect_id", config.displayNameEffect),
+                ("display_name_colors", config.displayNameColors),
+            )
+            if value is not None
+        }
+        if not fields:
+            return
+
+        for guild in self.guilds:
+            try:
+                await self.http.edit_my_member(guild.id, **fields)
+            except discord.HTTPException as e:
+                print(cf.red(f"[style] couldn't style my name in {guild.id}: {e}"))
+            else:
+                print(cf.yellow(f"[style] name style set in {guild.name}"))
+
     async def on_ready(self) -> None:
         if not self._profileSet:
             self._profileSet = True
@@ -159,6 +230,7 @@ class Bot(commands.Bot):
                 print(cf.yellow("Avatar and Banner loaded!"))
             except (discord.HTTPException, OSError) as e:
                 print(cf.red(f"Failed to set avatar/banner: {e}"))
+            await self.applyNameStyle()
         print(cf.magenta(f"Logged in as {self.user}"))
 
 
diff --git a/sandrone/config.py b/sandrone/config.py
index 600359d..fd1205d 100644
--- a/sandrone/config.py
+++ b/sandrone/config.py
@@ -56,6 +56,16 @@ downloadsMaxSize = (
     int(os.getenv("DOWNLOADS_MAX_SIZE_MIB", "2048")) * 1024 * 1024
 )
 
+displayNameFont: int | None = 16
+displayNameEffect: int | None = 7
+displayNameColors: list[int] | None = [
+    0xD52D00,
+    0xFF9A56,
+    0xFFFFFF,
+    0xD362A4,
+    0xA30262,
+]
+
 owners: list[int] = [
     1464890289922641993,
     1025770042245251122,