Skip to content
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
49 changes: 49 additions & 0 deletions src/plugins/lockMyThreads/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { Devs } from "@utils/constants";
import { getIntlMessage } from "@utils/discord";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { Menu, PermissionsBits, PermissionStore, UserStore } from "@webpack/common";

const ThreadActions = findByPropsLazy("lockThread", "archiveThread");


function CreateLockContext(): NavContextMenuPatchCallback {
return (children, props) => {
if (props.channel.threadMetadata.locked) return;
const threadActions = children.find(child => {
return child?.key === "thread-actions";
});
if (PermissionStore.can(PermissionsBits.MANAGE_THREADS, props.channel)) return;
const archiveButton = threadActions?.props.children.find(child => {
return child?.props.id === "archive-thread" || child?.props.id === "unarchive-thread";
});
const { ownerId } = props.channel;
const currentUser = UserStore.getCurrentUser();
if (ownerId !== currentUser.id) return;
let lockLabel = getIntlMessage("LOCK_THREAD");
if (props.channel.parentChannelThreadType === 15 || props.channel.parentChannelThreadType === 16) lockLabel = getIntlMessage("LOCK_FORUM_POST");
const archiveButtonIndex = threadActions?.props.children.indexOf(archiveButton);
threadActions?.props.children.splice(archiveButtonIndex + 1, 0,
<Menu.MenuItem
id={"vc-lock-thread"}
label={lockLabel}
action={() => { ThreadActions.lockThread(props.channel); }}
/>);
};
}

export default definePlugin({
name: "LockMyThreads",
description: "Enabled a lock thread button for your own threads, even if you don't have manage threads permission.",
authors: [Devs.ariflan],
contextMenus: {
"thread-context": CreateLockContext()
}
});
4 changes: 4 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "thororen",
id: 848339671629299742n
},
ariflan: {
name: "ariflan",
id: 581462944953663508n
}
} satisfies Record<string, Dev>);

// iife so #__PURE__ works correctly
Expand Down