fix(auto_reactions): fix error if the bot member cannot be found in the server

This commit is contained in:
Dragory 2021-10-17 11:32:52 +03:00
parent 9562f9d528
commit 9180be75b7
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -19,17 +19,21 @@ export const AddReactionsEvt = autoReactionsEvt({
if (!autoReaction) return;
const me = pluginData.guild.members.cache.get(pluginData.client.user!.id)!;
const missingPermissions = getMissingChannelPermissions(
me,
message.channel as GuildChannel,
readChannelPermissions | p.ADD_REACTIONS,
);
if (missingPermissions) {
const logs = pluginData.getPlugin(LogsPlugin);
logs.logBotAlert({
body: `Cannot apply auto-reactions in <#${message.channel.id}>. ${missingPermissionError(missingPermissions)}`,
});
return;
if (me) {
const missingPermissions = getMissingChannelPermissions(
me,
message.channel as GuildChannel,
readChannelPermissions | p.ADD_REACTIONS,
);
if (missingPermissions) {
const logs = pluginData.getPlugin(LogsPlugin);
logs.logBotAlert({
body: `Cannot apply auto-reactions in <#${message.channel.id}>. ${missingPermissionError(
missingPermissions,
)}`,
});
return;
}
}
for (const reaction of autoReaction.reactions) {