Improved Evil Mode toggle to handle edge cases of the pfp and role color change. Japanese swallow model compatible (should be).
This commit is contained in:
@@ -358,6 +358,45 @@ async def cleanup_webhooks(client):
|
||||
return cleaned_count
|
||||
|
||||
|
||||
async def update_webhook_avatars(client):
|
||||
"""Update all bipolar webhook avatars with current profile pictures"""
|
||||
updated_count = 0
|
||||
|
||||
# Load current avatar images
|
||||
miku_avatar = None
|
||||
evil_avatar = None
|
||||
|
||||
miku_pfp_path = "memory/profile_pictures/current.png"
|
||||
evil_pfp_path = "memory/profile_pictures/evil_pfp.png"
|
||||
|
||||
if os.path.exists(miku_pfp_path):
|
||||
with open(miku_pfp_path, "rb") as f:
|
||||
miku_avatar = f.read()
|
||||
|
||||
if os.path.exists(evil_pfp_path):
|
||||
with open(evil_pfp_path, "rb") as f:
|
||||
evil_avatar = f.read()
|
||||
|
||||
# Update webhooks in all servers
|
||||
for guild in client.guilds:
|
||||
try:
|
||||
guild_webhooks = await guild.webhooks()
|
||||
for webhook in guild_webhooks:
|
||||
if webhook.name == "Miku (Bipolar)" and miku_avatar:
|
||||
await webhook.edit(avatar=miku_avatar, reason="Update Miku avatar")
|
||||
updated_count += 1
|
||||
logger.debug(f"Updated Miku webhook avatar in {guild.name}")
|
||||
elif webhook.name == "Evil Miku (Bipolar)" and evil_avatar:
|
||||
await webhook.edit(avatar=evil_avatar, reason="Update Evil Miku avatar")
|
||||
updated_count += 1
|
||||
logger.debug(f"Updated Evil Miku webhook avatar in {guild.name}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to update webhooks in {guild.name}: {e}")
|
||||
|
||||
logger.info(f"Updated {updated_count} bipolar webhook avatar(s)")
|
||||
return updated_count
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# DISPLAY NAME HELPERS
|
||||
# ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user