Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit eb4fa31

Browse files
committed
improve warning and publish lodestone is down error
1 parent 2ab6df1 commit eb4fa31

3 files changed

Lines changed: 33 additions & 32 deletions

File tree

src/command/ContextFindCommand.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { ProfileGeneratorService } from "../service/ProfileGeneratorService.ts";
44
import { FetchCharacterService } from "../service/FetchCharacterService.ts";
55
import { Command } from "./type/Command.ts";
66
import { DiscordMessageService } from "../service/DiscordMessageService.ts";
7-
import { DiscordEmbedService } from "../service/DiscordEmbedService.ts";
87
import { LodestoneServiceUnavailableError } from "../naagostone/error/LodestoneServiceUnavailableError.ts";
98

109
class ContextFindCommand extends Command {
@@ -50,14 +49,14 @@ class ContextFindCommand extends Command {
5049
const components = ProfileGeneratorService.getComponents("profile", null, "profile", targetCharacter?.id);
5150
const unix = targetCharacterDataDto.latestUpdate.unix();
5251

53-
const embeds = targetCharacterDataDto.isCachedDueToUnavailability
54-
? [DiscordEmbedService.getErrorEmbed("Lodestone is currently unavailable. Showing cached data.")]
55-
: [];
52+
const cachedHint = targetCharacterDataDto.isCachedDueToUnavailability
53+
? "\n⚠️ *Lodestone is currently unavailable. Showing cached data.*"
54+
: "";
5655

5756
await interaction.editReply({
58-
content: `Latest Update: <t:${unix}:R>`,
57+
content: `Latest Update: <t:${unix}:R>${cachedHint}`,
5958
files: [file],
60-
embeds,
59+
embeds: [],
6160
attachments: [],
6261
components: components,
6362
});

src/command/ProfileCommand.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ class ProfileCommand extends Command {
124124
throw new Error("[/profile me] profilePage is undefined");
125125
}
126126

127-
const embeds = characterDataDto.isCachedDueToUnavailability
128-
? [DiscordEmbedService.getErrorEmbed("Lodestone is currently unavailable. Showing cached data.")]
129-
: [];
127+
const cachedHint = characterDataDto.isCachedDueToUnavailability
128+
? "\n⚠️ *Lodestone is currently unavailable. Showing cached data.*"
129+
: "";
130130

131131
if (profilePage === "portrait") {
132132
const response = await fetch(character.portrait);
@@ -136,9 +136,9 @@ class ProfileCommand extends Command {
136136
const components = ProfileGeneratorService.getComponents(profilePage, subProfilePage, "profile", characterId);
137137

138138
await interaction.editReply({
139-
content: `${character.name}🌸${character.server.world}`,
139+
content: `${character.name}🌸${character.server.world}${cachedHint}`,
140140
files: [file],
141-
embeds,
141+
embeds: [],
142142
attachments: [],
143143
components: components,
144144
});
@@ -152,9 +152,9 @@ class ProfileCommand extends Command {
152152
const components = ProfileGeneratorService.getComponents(profilePage, subProfilePage, "profile", characterId);
153153

154154
await interaction.editReply({
155-
content: `Latest Update: <t:${characterDataDto.latestUpdate.unix()}:R>`,
155+
content: `Latest Update: <t:${characterDataDto.latestUpdate.unix()}:R>${cachedHint}`,
156156
files: [file],
157-
embeds,
157+
embeds: [],
158158
attachments: [],
159159
components: components,
160160
});
@@ -178,7 +178,8 @@ class ProfileCommand extends Command {
178178
characterIds = await NaagostoneApiService.fetchCharacterIdsByName(name, server);
179179
} catch (error: unknown) {
180180
if (error instanceof LodestoneServiceUnavailableError) {
181-
await DiscordMessageService.deleteAndFollowUpEphemeralError(interaction, error.message);
181+
const embed = DiscordEmbedService.getErrorEmbed(error.message);
182+
await interaction.editReply({ embeds: [embed] });
182183
return;
183184
}
184185
throw error;
@@ -207,7 +208,8 @@ class ProfileCommand extends Command {
207208
characterDataDto = await FetchCharacterService.fetchCharacterCached(interaction, characterId);
208209
} catch (error: unknown) {
209210
if (error instanceof LodestoneServiceUnavailableError) {
210-
await DiscordMessageService.deleteAndFollowUpEphemeralError(interaction, error.message);
211+
const embed = DiscordEmbedService.getErrorEmbed(error.message);
212+
await interaction.editReply({ embeds: [embed] });
211213
return;
212214
}
213215
throw error;
@@ -231,14 +233,14 @@ class ProfileCommand extends Command {
231233
const file = new AttachmentBuilder(profileImage);
232234
const components = ProfileGeneratorService.getComponents("profile", null, "profile", characterId);
233235

234-
const embeds = characterDataDto.isCachedDueToUnavailability
235-
? [DiscordEmbedService.getErrorEmbed("Lodestone is currently unavailable. Showing cached data.")]
236-
: [];
236+
const cachedHint = characterDataDto.isCachedDueToUnavailability
237+
? "\n⚠️ *Lodestone is currently unavailable. Showing cached data.*"
238+
: "";
237239

238240
await interaction.editReply({
239-
content: `Latest Update: <t:${characterDataDto.latestUpdate.unix()}:R>`,
241+
content: `Latest Update: <t:${characterDataDto.latestUpdate.unix()}:R>${cachedHint}`,
240242
files: [file],
241-
embeds,
243+
embeds: [],
242244
attachments: [],
243245
components: components,
244246
});

src/helper/ProfileCommandHelper.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export class ProfileCommandHandler {
5353
ProfilePagesRepository.set(userId, actualProfilePage, subProfilePage);
5454
}
5555

56-
const embeds = characterDataDto.isCachedDueToUnavailability
57-
? [DiscordEmbedService.getErrorEmbed("Lodestone is currently unavailable. Showing cached data.")]
58-
: [];
56+
const cachedHint = characterDataDto.isCachedDueToUnavailability
57+
? "\n⚠️ *Lodestone is currently unavailable. Showing cached data.*"
58+
: "";
5959

6060
if (actualProfilePage === "portrait") {
6161
const response = await fetch(character.portrait);
@@ -70,9 +70,9 @@ export class ProfileCommandHandler {
7070
);
7171

7272
await interaction.editReply({
73-
content: `${character.name}🌸${character.server.world}`,
73+
content: `${character.name}🌸${character.server.world}${cachedHint}`,
7474
files: [file],
75-
embeds,
75+
embeds: [],
7676
attachments: [],
7777
components: components,
7878
});
@@ -88,9 +88,9 @@ export class ProfileCommandHandler {
8888
const components = ProfileGeneratorService.getComponents(actualProfilePage, subProfilePage, "profile", characterId);
8989

9090
await interaction.editReply({
91-
content: `Latest Update: <t:${characterDataDto.latestUpdate.unix()}:R>`,
91+
content: `Latest Update: <t:${characterDataDto.latestUpdate.unix()}:R>${cachedHint}`,
9292
files: [file],
93-
embeds,
93+
embeds: [],
9494
attachments: [],
9595
components: components,
9696
});
@@ -135,14 +135,14 @@ export class ProfileCommandHandler {
135135
const file = new AttachmentBuilder(profileImage);
136136
const components = ProfileGeneratorService.getComponents("profile", null, "profile", characterId);
137137

138-
const embeds = characterDataDto.isCachedDueToUnavailability
139-
? [DiscordEmbedService.getErrorEmbed("Lodestone is currently unavailable. Showing cached data.")]
140-
: [];
138+
const cachedHint = characterDataDto.isCachedDueToUnavailability
139+
? "\n⚠️ *Lodestone is currently unavailable. Showing cached data.*"
140+
: "";
141141

142142
await interaction.editReply({
143-
content: `Latest Update: <t:${characterDataDto.latestUpdate.unix()}:R>`,
143+
content: `Latest Update: <t:${characterDataDto.latestUpdate.unix()}:R>${cachedHint}`,
144144
files: [file],
145-
embeds,
145+
embeds: [],
146146
attachments: [],
147147
components: components,
148148
});

0 commit comments

Comments
 (0)