Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Plugin: Message Jumper #3207

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions src/plugins/messageJumper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { ChannelRouter, ChannelStore, SelectedChannelStore } from "@webpack/common";
import { Message } from "discord-types/general";

interface IMessageCreate {
type: "MESSAGE_CREATE";
optimistic: boolean;
isPushNotification: boolean;
channelId: string;
message: Message;
}


const settings = definePluginSettings({
whitelistedServers: {
type: OptionType.SELECT,
description: "Whether to use ID list as blacklist or whitelist",
options: [
{
label: "Blacklist",
value: "blacklist",
default: true
},
{
label: "Whitelist",
value: "whitelist"
}
],
default: "Blacklist"
},
servers: {
type: OptionType.STRING,
description: "Blacklisted/Whitelisted server ids, separated by commas",
default: "",
},
whitelistedChannels: {
type: OptionType.SELECT,
description: "Whether to use ID list as blacklist or whitelist",
options: [
{
label: "Blacklist",
value: "blacklist",
default: true
},
{
label: "Whitelist",
value: "whitelist"
}
],
default: "Blacklist"
},
channels: {
type: OptionType.STRING,
description: "Blacklisted/Whitelisted channel ids, separated by commas",
default: "",
},
});

export default definePlugin({
name: "MessageJumper",
description: "Auto jumps to channels with new messages",
authors: [Devs.may2bee],
settings,

flux: {
async MESSAGE_CREATE({ optimistic, type, message, channelId }: IMessageCreate) {
if (optimistic || type !== "MESSAGE_CREATE") return;
if (SelectedChannelStore.getChannelId() === channelId) return;
const channel = ChannelStore.getChannel(channelId);
if (document.hasFocus()) return;

const { whitelistedServers, servers, whitelistedChannels, channels } = settings.store;

const serverIds = servers.split(",").map(id => id.trim());
if (whitelistedServers === "whitelist") {
if (!serverIds.includes(channel.guild_id)) {
return;
}
} else {
if (serverIds.includes(channel.guild_id)) {
return;
}
}

const channelIds = channels!!.split(",").map(id => id.trim());
if (whitelistedChannels === "whitelist") {
if (!channelIds.includes(channelId)) {
return;
}
} else {
if (channelIds.includes(channelId)) {
return;
}
}

ChannelRouter.transitionToChannel(channelId);
},
}
});
4 changes: 4 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "jamesbt365",
id: 158567567487795200n,
},
may2bee: {
name: "May2Bee",
id: 174929158294470656n,
},
} satisfies Record<string, Dev>);

// iife so #__PURE__ works correctly
Expand Down