Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

Expand All @@ -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];
}
}

Expand All @@ -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];
}
}

Expand Down
Loading