Skip to content

Commit

Permalink
don't crash because of missing permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnniee committed Oct 31, 2022
1 parent 4c93995 commit 48d6186
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/plugins/messageLinkEmbeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ export default definePlugin({
return Nothing;
}
const linkedChannel = ChannelStore.getChannel(channelID);
if (!linkedChannel) {
elementCache[messageID] = {
element: Nothing,
shouldRenderRichEmbed: true
};
return Nothing;
}
const isDM = guildID === "@me";
const images = getImages(linkedMessage);
const hasActualEmbed = (linkedMessage.author.bot
Expand Down Expand Up @@ -289,14 +296,16 @@ export default definePlugin({
_messageEmbed: "clyde"
}] as Embed[];
}
const channel = ChannelStore.getChannel(channelID);
if (!channel) return [...existingEmbeds];

const firstEmbed = message.embeds[0] as Embed;
const hasActualEmbed = !!(message.author.bot && firstEmbed?.type === "rich" && firstEmbed.id.match(/embed_\d+/));
if (hasActualEmbed && message.content) return [...existingEmbeds, { ...firstEmbed, _messageEmbed: "rich" }];

const usernameAndDiscriminator = `${message.author.username}#${message.author.discriminator}`;
const channelAndServer = guildID === "@me" ? "Direct Message" :
"#" + ChannelStore.getChannel(channelID).name + ` (${GuildStore.getGuild(guildID).name})`;
"#" + channel.name + ` (${GuildStore.getGuild(guildID).name})`;

const embeds = [...existingEmbeds, {
author: {
Expand Down

0 comments on commit 48d6186

Please sign in to comment.