|
1 | 1 | import { Container } from "@/app/Container";
|
2 | 2 | import { Data, GameBridge, Service } from "@/app/services";
|
| 3 | +import { getAsBase64 } from "@/utils"; |
3 | 4 | import Discord from "discord.js";
|
4 | 5 | import DiscordConfig from "@/config/discord.json";
|
5 | 6 | import modules from "./modules";
|
@@ -125,8 +126,10 @@ export class DiscordBot extends Service {
|
125 | 126 | try {
|
126 | 127 | const guild = this.getGuild();
|
127 | 128 | if (!guild) return false;
|
128 |
| - this.data.lastDiscordGuildIcon = |
129 |
| - this.discord.user.avatarURL() ?? guild.iconURL() ?? this.data.lastDiscordGuildIcon; |
| 129 | + const iconURL = this.discord.user.avatarURL() ?? guild.iconURL(); |
| 130 | + this.data.lastDiscordGuildIcon = iconURL |
| 131 | + ? (await getAsBase64(iconURL)) ?? this.data.lastDiscordGuildIcon |
| 132 | + : this.data.lastDiscordGuildIcon; |
130 | 133 | await this.data.save();
|
131 | 134 | await this.discord.user.setAvatar(path);
|
132 | 135 | await guild.setIcon(path, reason);
|
@@ -163,9 +166,13 @@ export class DiscordBot extends Service {
|
163 | 166 | if (!this.ready || !(await this.overLvl2())) return false;
|
164 | 167 | try {
|
165 | 168 | const guild = this.getGuild();
|
166 |
| - this.data.lastDiscordBanner = guild?.bannerURL() ?? this.data.lastDiscordBanner; |
| 169 | + if (!guild) return false; |
| 170 | + const bannerURL = guild.bannerURL(); |
| 171 | + this.data.lastDiscordBanner = bannerURL |
| 172 | + ? (await getAsBase64(bannerURL)) ?? this.data.lastDiscordBanner |
| 173 | + : this.data.lastDiscordBanner; |
167 | 174 | await this.data.save();
|
168 |
| - await guild?.setBanner(url, reason); |
| 175 | + await guild.setBanner(url, reason); |
169 | 176 | return true;
|
170 | 177 | } catch {
|
171 | 178 | return false;
|
|
0 commit comments