NoReplyMention: add role whitelist / blacklist (#2794)

Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
union 2025-09-03 20:41:06 -04:00 committed by GitHub
parent 9700ec9cd2
commit b7f19bbe37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,7 @@ import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import type { Message } from "@vencord/discord-types"; import type { Message } from "@vencord/discord-types";
import { ChannelStore, GuildMemberStore } from "@webpack/common";
const settings = definePluginSettings({ const settings = definePluginSettings({
userList: { userList: {
@ -28,16 +29,22 @@ const settings = definePluginSettings({
type: OptionType.STRING, type: OptionType.STRING,
default: "1234567890123445,1234567890123445", default: "1234567890123445,1234567890123445",
}, },
roleList: {
description:
"List of roles to allow or exempt pings for (separated by commas or spaces)",
type: OptionType.STRING,
default: "1234567890123445,1234567890123445",
},
shouldPingListed: { shouldPingListed: {
description: "Behaviour", description: "Behaviour",
type: OptionType.SELECT, type: OptionType.SELECT,
options: [ options: [
{ {
label: "Do not ping the listed users", label: "Do not ping the listed users / roles",
value: false, value: false,
}, },
{ {
label: "Only ping the listed users", label: "Only ping the listed users / roles",
value: true, value: true,
default: true, default: true,
}, },
@ -57,7 +64,14 @@ export default definePlugin({
settings, settings,
shouldMention(message: Message, isHoldingShift: boolean) { shouldMention(message: Message, isHoldingShift: boolean) {
const isListed = settings.store.userList.includes(message.author.id); let isListed = settings.store.userList.includes(message.author.id);
const channel = ChannelStore.getChannel(message.channel_id);
if (channel?.guild_id && !isListed) {
const roles = GuildMemberStore.getMember(channel.guild_id, message.author.id)?.roles;
isListed = !!roles && roles.some(role => settings.store.roleList.includes(role));
}
const isExempt = settings.store.shouldPingListed ? isListed : !isListed; const isExempt = settings.store.shouldPingListed ? isListed : !isListed;
return settings.store.inverseShiftReply ? isHoldingShift !== isExempt : !isHoldingShift && isExempt; return settings.store.inverseShiftReply ? isHoldingShift !== isExempt : !isHoldingShift && isExempt;
}, },