mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-18 16:34:27 -04:00
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:
+24
-12
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user