mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 22:23:02 -04:00
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:
parent
238482a0b7
commit
281e9caeff
3 changed files with 74 additions and 8 deletions
69
src/equicordplugins/autoJump/index.tsx
Normal file
69
src/equicordplugins/autoJump/index.tsx
Normal 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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -21,12 +21,9 @@ import "@equicordplugins/_misc/styles.css";
|
||||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands";
|
import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands";
|
||||||
import { Devs, EquicordDevs } from "@utils/constants";
|
import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { Forms, MessageActions, MessageStore, UserStore } from "@webpack/common";
|
||||||
import { Forms, MessageStore, UserStore } from "@webpack/common";
|
|
||||||
import { Channel, Message } from "discord-types/general";
|
import { Channel, Message } from "discord-types/general";
|
||||||
|
|
||||||
const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage");
|
|
||||||
|
|
||||||
async function deleteMessages(amount: number, channel: Channel, delay: number = 1500): Promise<number> {
|
async function deleteMessages(amount: number, channel: Channel, delay: number = 1500): Promise<number> {
|
||||||
let deleted = 0;
|
let deleted = 0;
|
||||||
const userId = UserStore.getCurrentUser().id;
|
const userId = UserStore.getCurrentUser().id;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue