fix: markdownToTextFetch will now return results even if fetches fail (#135)

This commit was made without the use of generative AI.

Signed-off-by: Jacob Schlecht <dadadah@echoha.us>
This commit is contained in:
Jacob Schlecht
2026-03-02 20:47:27 -07:00
committed by GitHub
parent 64d8d2c657
commit 3c71fa73e8
+24 -12
View File
@@ -455,10 +455,14 @@ export class Client extends AsyncEventEmitter<Events> {
async (key) => {
const substr = userMatches[key];
if (substr) {
const user = await this.users.fetch(substr);
if (user) {
return [key, `@${user.username}`];
try {
const user = await this.users.fetch(substr);
if (user) {
return [key, `@${user.username}`];
}
} catch {
// If the fetch fails, just show the match as a default
return [key, key];
}
}
@@ -471,10 +475,14 @@ export class Client extends AsyncEventEmitter<Events> {
async (key) => {
const substr = channelMatches[key];
if (substr) {
const channel = await this.channels.fetch(substr);
if (channel) {
return [key, `#${channel.displayName}`];
try {
const channel = await this.channels.fetch(substr);
if (channel) {
return [key, `#${channel.displayName}`];
}
} catch {
// If the fetch fails, just show the match as a default
return [key, key];
}
}
@@ -487,10 +495,14 @@ export class Client extends AsyncEventEmitter<Events> {
async (key) => {
const substr = customEmojiMatches[key];
if (substr) {
const emoji = await this.emojis.fetch(substr);
if (emoji) {
return [key, `:${emoji.name}:`];
try {
const emoji = await this.emojis.fetch(substr);
if (emoji) {
return [key, `:${emoji.name}:`];
}
} catch {
// If the fetch fails, just show the match as a default
return [key, key];
}
}