aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRyan Cao <70191398+ryanccn@users.noreply.github.com>2023-07-26 07:41:41 +0800
committerGitHub <noreply@github.com>2023-07-26 01:41:41 +0200
commitc69c6f8cb7f9d4afba04f385bd6f2757d9b04c86 (patch)
treeeb1501bc6a8f2715c8daf152e6f7435bb888faa7 /src
parentf2c6fcaa3bc8601e30f79ba34ad8388c3a0a1e4a (diff)
downloadVencord-c69c6f8cb7f9d4afba04f385bd6f2757d9b04c86.tar.gz
Vencord-c69c6f8cb7f9d4afba04f385bd6f2757d9b04c86.tar.bz2
Vencord-c69c6f8cb7f9d4afba04f385bd6f2757d9b04c86.zip
feat(MessageLinkEmbeds): add whitelist/blacklist modes (#813)
Co-authored-by: V <vendicated@riseup.net>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/messageLinkEmbeds.tsx33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/plugins/messageLinkEmbeds.tsx b/src/plugins/messageLinkEmbeds.tsx
index 5fae234..5e9eff2 100644
--- a/src/plugins/messageLinkEmbeds.tsx
+++ b/src/plugins/messageLinkEmbeds.tsx
@@ -93,6 +93,26 @@ const settings = definePluginSettings({
}
]
},
+ listMode: {
+ description: "Whether to use ID list as blacklist or whitelist",
+ type: OptionType.SELECT,
+ options: [
+ {
+ label: "Blacklist",
+ value: "blacklist",
+ default: true
+ },
+ {
+ label: "Whitelist",
+ value: "whitelist"
+ }
+ ]
+ },
+ idList: {
+ description: "Guild/channel/user IDs to blacklist or whitelist (separate with comma)",
+ type: OptionType.STRING,
+ default: ""
+ },
clearMessageCache: {
type: OptionType.COMPONENT,
description: "Clear the linked message cache",
@@ -217,6 +237,13 @@ function MessageEmbedAccessory({ message }: { message: Message; }) {
continue;
}
+ const { listMode, idList } = settings.store;
+
+ const isListed = [guildID, channelID, message.author.id].some(id => id && idList.includes(id));
+
+ if (listMode === "blacklist" && isListed) continue;
+ if (listMode === "whitelist" && !isListed) continue;
+
let linkedMessage = messageCache.get(messageID)?.message;
if (!linkedMessage) {
linkedMessage ??= MessageStore.getMessage(channelID, messageID);
@@ -335,7 +362,7 @@ function AutomodEmbedAccessory(props: MessageEmbedProps): JSX.Element | null {
export default definePlugin({
name: "MessageLinkEmbeds",
description: "Adds a preview to messages that link another message",
- authors: [Devs.TheSun, Devs.Ven],
+ authors: [Devs.TheSun, Devs.Ven, Devs.RyanCaoDev],
dependencies: ["MessageAccessoriesAPI"],
patches: [
{
@@ -363,7 +390,9 @@ export default definePlugin({
return (
<ErrorBoundary>
- <MessageEmbedAccessory message={props.message} />
+ <MessageEmbedAccessory
+ message={props.message}
+ />
</ErrorBoundary>
);
}, 4 /* just above rich embeds */);