Skip to content

Commit

Permalink
reset icon if no path is specified instead of using the last
Browse files Browse the repository at this point in the history
  • Loading branch information
Techbot121 authored and Meta Construct committed Jan 15, 2025
1 parent d38902d commit 6abdeea
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/services/discord/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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<boolean> {
async setIcon(path?: string, reason?: string): Promise<boolean> {
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
Expand Down

0 comments on commit 6abdeea

Please sign in to comment.