starboard: fix category overrides not working

This commit is contained in:
Dragory 2020-07-30 02:02:32 +03:00
parent 7fb7787583
commit e7d647f1e6
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -1,6 +1,6 @@
import { starboardEvt } from "../types";
import { Message } from "eris";
import { UnknownUser, resolveMember, noop } from "src/utils";
import { Message, TextChannel } from "eris";
import { UnknownUser, resolveMember, noop, resolveUser } from "src/utils";
import { saveMessageToStarboard } from "../util/saveMessageToStarboard";
export const StarboardReactionAddEvt = starboardEvt({
@ -26,11 +26,15 @@ export const StarboardReactionAddEvt = starboardEvt({
// No self-votes!
if (msg.author.id === userId) return;
const user = await resolveMember(pluginData.client, pluginData.guild, userId);
if (user instanceof UnknownUser) return;
if (user.bot) return;
const member = await resolveMember(pluginData.client, pluginData.guild, userId);
if (!member || member.bot) return;
const config = pluginData.config.getMatchingConfig({
member,
channelId: msg.channel.id,
categoryId: (msg.channel as TextChannel).parentID,
});
const config = pluginData.config.getMatchingConfig({ member: user, channelId: msg.channel.id });
const applicableStarboards = Object.values(config.boards)
.filter(board => board.enabled)
// Can't star messages in the starboard channel itself