add (autoJump) (#245)

* Create index.tsx

* Update index.tsx

* Create index.tsx

* Update index.tsx

* Update index.tsx

* Create index.tsx

* Delete index.tsx

* Delete index.tsx

* Create index.tsx

* update plugin-settings / main settings

yep

* Delete index.tsx

* Revert

* Add AutoJump

* Only Trigger Flux On Setting

* Remove Extra Auto

* Misc Fix

---------

Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
Eazvy 2025-05-04 23:40:40 -04:00 committed by GitHub
parent 238482a0b7
commit 281e9caeff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 74 additions and 8 deletions

View file

@ -263,7 +263,7 @@
&:hover {
background-color: var(--card-primary-bg) !important;
}
}
}
.visual-refresh .vc-plugin-stats {
background-color: var(--card-primary-bg) !important;

View file

@ -0,0 +1,69 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { definePluginSettings } from "@api/Settings";
import { EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { ChannelStore, Menu, MessageActions, NavigationRouter } from "@webpack/common";
interface ChannelSelectEvent {
type: "CHANNEL_SELECT";
channelId: string | null;
guildId: string | null;
}
let lastChannelId = "0";
function autoJump({ guild_id, id: channelId }) {
const guildId = guild_id ?? "@me";
lastChannelId = channelId;
NavigationRouter.transitionTo(`/channels/${guildId}/${channelId}`);
MessageActions.jumpToPresent(channelId, { limit: null });
}
const MenuPatch: NavContextMenuPatchCallback = (children, { channel }) => {
children.push(
<Menu.MenuItem
id="auto-jump"
label="Jump to Last Message"
action={() => {
autoJump(channel);
}}
/>
);
};
const settings = definePluginSettings({
autoJumping: {
type: OptionType.BOOLEAN,
description: "Automatically jump to the last message in the channel when switching channels",
default: false
}
});
export default definePlugin({
name: "AutoJump",
description: "Jumps to Last Message in Channel",
authors: [EquicordDevs.omaw],
settings,
contextMenus: {
"channel-context": MenuPatch,
"user-context": MenuPatch,
"thread-context": MenuPatch
},
flux: {
async CHANNEL_SELECT({ guildId, channelId }: ChannelSelectEvent) {
if (!settings.store.autoJumping || !channelId) return;
const channel = ChannelStore.getChannel(channelId);
if (!channel || channel.id === lastChannelId) return;
autoJump({ guild_id: guildId, id: channelId });
}
}
});

View file

@ -21,12 +21,9 @@ import "@equicordplugins/_misc/styles.css";
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands";
import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { Forms, MessageStore, UserStore } from "@webpack/common";
import { Forms, MessageActions, MessageStore, UserStore } from "@webpack/common";
import { Channel, Message } from "discord-types/general";
const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage");
async function deleteMessages(amount: number, channel: Channel, delay: number = 1500): Promise<number> {
let deleted = 0;
const userId = UserStore.getCurrentUser().id;