NoReplyMention: add role whitelist / blacklist (#2794)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
9700ec9cd2
commit
b7f19bbe37
1 changed files with 17 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import type { Message } from "@vencord/discord-types";
|
||||
import { ChannelStore, GuildMemberStore } from "@webpack/common";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
userList: {
|
||||
|
|
@ -28,16 +29,22 @@ const settings = definePluginSettings({
|
|||
type: OptionType.STRING,
|
||||
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: {
|
||||
description: "Behaviour",
|
||||
type: OptionType.SELECT,
|
||||
options: [
|
||||
{
|
||||
label: "Do not ping the listed users",
|
||||
label: "Do not ping the listed users / roles",
|
||||
value: false,
|
||||
},
|
||||
{
|
||||
label: "Only ping the listed users",
|
||||
label: "Only ping the listed users / roles",
|
||||
value: true,
|
||||
default: true,
|
||||
},
|
||||
|
|
@ -57,7 +64,14 @@ export default definePlugin({
|
|||
settings,
|
||||
|
||||
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;
|
||||
return settings.store.inverseShiftReply ? isHoldingShift !== isExempt : !isHoldingShift && isExempt;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue