From 6abdeea5db28a2a3e7092e6081e503b49e523809 Mon Sep 17 00:00:00 2001 From: Techbot121 Date: Wed, 15 Jan 2025 17:29:20 +0100 Subject: [PATCH] reset icon if no path is specified instead of using the last --- app/services/discord/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/services/discord/index.ts b/app/services/discord/index.ts index cc1605b..e249117 100644 --- a/app/services/discord/index.ts +++ b/app/services/discord/index.ts @@ -1,6 +1,7 @@ import { Container } from "@/app/Container"; import { Data, GameBridge, Service } from "@/app/services"; import { getAsBase64 } from "@/utils"; +import { getEventIcon } from "./modules/discord-guild-icon"; import Discord from "discord.js"; import DiscordConfig from "@/config/discord.json"; import modules from "./modules"; @@ -118,14 +119,16 @@ export class DiscordBot extends Service { } // sets both the bot's avatar and the guild's icon - async setIcon( - path = this.data.lastDiscordGuildIcon ?? "resources/discord-guild-icons/default.png", - reason?: string - ): Promise { + async setIcon(path?: string, reason?: string): Promise { if (!this.ready || !this.discord.user) return false; try { const guild = this.getGuild(); if (!guild) return false; + + if (!path) { + path = (await getEventIcon()).filePath; + } + const iconURL = this.discord.user.avatarURL() ?? guild.iconURL(); this.data.lastDiscordGuildIcon = iconURL ? (await getAsBase64(iconURL)) ?? this.data.lastDiscordGuildIcon