SupportHelper: Enable in more channels
This commit is contained in:
parent
b3bff83dd5
commit
d62be1b94a
3 changed files with 25 additions and 19 deletions
|
@ -22,7 +22,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
|||
import { Flex } from "@components/Flex";
|
||||
import { Link } from "@components/Link";
|
||||
import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab";
|
||||
import { CONTRIB_ROLE_ID, Devs, DONOR_ROLE_ID, KNOWN_ISSUES_CHANNEL_ID, REGULAR_ROLE_ID, SUPPORT_CHANNEL_ID, VENBOT_USER_ID, VENCORD_GUILD_ID } from "@utils/constants";
|
||||
import { CONTRIB_ROLE_ID, Devs, DONOR_ROLE_ID, KNOWN_ISSUES_CHANNEL_ID, REGULAR_ROLE_ID, SUPPORT_CATEGORY_ID, SUPPORT_CHANNEL_ID, VENBOT_USER_ID, VENCORD_GUILD_ID } from "@utils/constants";
|
||||
import { sendMessage } from "@utils/discord";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { Margins } from "@utils/margins";
|
||||
|
@ -32,7 +32,8 @@ import { onlyOnce } from "@utils/onlyOnce";
|
|||
import { makeCodeblock } from "@utils/text";
|
||||
import definePlugin from "@utils/types";
|
||||
import { checkForUpdates, isOutdated, update } from "@utils/updater";
|
||||
import { Alerts, Button, Card, ChannelStore, Forms, GuildMemberStore, Parser, RelationshipStore, showToast, Text, Toasts, UserStore } from "@webpack/common";
|
||||
import { Alerts, Button, Card, ChannelStore, Forms, GuildMemberStore, Parser, PermissionsBits, PermissionStore, RelationshipStore, showToast, Text, Toasts, UserStore } from "@webpack/common";
|
||||
import { Channel } from "discord-types/general";
|
||||
import { JSX } from "react";
|
||||
|
||||
import gitHash from "~git-hash";
|
||||
|
@ -42,10 +43,8 @@ import SettingsPlugin from "./settings";
|
|||
|
||||
const CodeBlockRe = /```js\n(.+?)```/s;
|
||||
|
||||
const AllowedChannelIds = [
|
||||
SUPPORT_CHANNEL_ID,
|
||||
const AdditionalAllowedChannelIds = [
|
||||
"1024286218801926184", // Vencord > #bot-spam
|
||||
"1033680203433660458", // Vencord > #v
|
||||
];
|
||||
|
||||
const TrustedRolesIds = [
|
||||
|
@ -58,6 +57,8 @@ const AsyncFunction = async function () { }.constructor;
|
|||
|
||||
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame")!;
|
||||
|
||||
const isSupportAllowedChannel = (channel: Channel) => channel.parent_id === SUPPORT_CATEGORY_ID || AdditionalAllowedChannelIds.includes(channel.id);
|
||||
|
||||
async function forceUpdate() {
|
||||
const outdated = await checkForUpdates();
|
||||
if (outdated) {
|
||||
|
@ -155,20 +156,21 @@ export default definePlugin({
|
|||
{
|
||||
name: "vencord-debug",
|
||||
description: "Send Vencord debug info",
|
||||
predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || AllowedChannelIds.includes(ctx.channel.id),
|
||||
predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || isSupportAllowedChannel(ctx.channel),
|
||||
execute: async () => ({ content: await generateDebugInfoMessage() })
|
||||
},
|
||||
{
|
||||
name: "vencord-plugins",
|
||||
description: "Send Vencord plugin list",
|
||||
predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || AllowedChannelIds.includes(ctx.channel.id),
|
||||
predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || isSupportAllowedChannel(ctx.channel),
|
||||
execute: () => ({ content: generatePluginList() })
|
||||
}
|
||||
],
|
||||
|
||||
flux: {
|
||||
async CHANNEL_SELECT({ channelId }) {
|
||||
if (channelId !== SUPPORT_CHANNEL_ID) return;
|
||||
const isSupportChannel = channelId === SUPPORT_CHANNEL_ID || ChannelStore.getChannel(channelId)?.parent_id === SUPPORT_CATEGORY_ID;
|
||||
if (!isSupportChannel) return;
|
||||
|
||||
const selfId = UserStore.getCurrentUser()?.id;
|
||||
if (!selfId || isPluginDev(selfId)) return;
|
||||
|
@ -239,7 +241,7 @@ export default definePlugin({
|
|||
!IS_UPDATER_DISABLED
|
||||
&& (
|
||||
(props.channel.id === KNOWN_ISSUES_CHANNEL_ID) ||
|
||||
(props.channel.id === SUPPORT_CHANNEL_ID && props.message.author.id === VENBOT_USER_ID)
|
||||
(props.channel.parent_id === SUPPORT_CATEGORY_ID && props.message.author.id === VENBOT_USER_ID)
|
||||
)
|
||||
&& props.message.content?.includes("update");
|
||||
|
||||
|
@ -265,7 +267,7 @@ export default definePlugin({
|
|||
);
|
||||
}
|
||||
|
||||
if (props.channel.id === SUPPORT_CHANNEL_ID) {
|
||||
if (props.channel.parent_id === SUPPORT_CATEGORY_ID && PermissionStore.can(PermissionsBits.SEND_MESSAGES, props.channel)) {
|
||||
if (props.message.content.includes("/vencord-debug") || props.message.content.includes("/vencord-plugins")) {
|
||||
buttons.push(
|
||||
<Button
|
||||
|
|
|
@ -42,13 +42,16 @@ const settings = definePluginSettings({
|
|||
addBack: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Add back the Discord context menus for images, links and the chat input bar",
|
||||
default: false,
|
||||
restartNeeded: true,
|
||||
// Web slate menu has proper spellcheck suggestions and image context menu is also pretty good,
|
||||
// so disable this by default. Vesktop just doesn't, so enable by default
|
||||
default: IS_VESKTOP,
|
||||
restartNeeded: true
|
||||
// so disable this by default. Vesktop just doesn't, so we force enable it there
|
||||
hidden: IS_VESKTOP,
|
||||
}
|
||||
});
|
||||
|
||||
const shouldAddBackMenus = () => IS_VESKTOP || settings.store.addBack;
|
||||
|
||||
const MEDIA_PROXY_URL = "https://media.discordapp.net";
|
||||
const CDN_URL = "cdn.discordapp.com";
|
||||
|
||||
|
@ -81,7 +84,7 @@ export default definePlugin({
|
|||
settings,
|
||||
|
||||
start() {
|
||||
if (settings.store.addBack) {
|
||||
if (shouldAddBackMenus()) {
|
||||
window.removeEventListener("contextmenu", ctxMenuCallbacks.contextMenuCallbackWeb);
|
||||
window.addEventListener("contextmenu", ctxMenuCallbacks.contextMenuCallbackNative);
|
||||
this.changedListeners = true;
|
||||
|
@ -144,7 +147,7 @@ export default definePlugin({
|
|||
{
|
||||
find: 'navId:"image-context"',
|
||||
all: true,
|
||||
predicate: () => settings.store.addBack,
|
||||
predicate: shouldAddBackMenus,
|
||||
replacement: {
|
||||
// return IS_DESKTOP ? React.createElement(Menu, ...)
|
||||
match: /return \i\.\i(?=\?|&&)/,
|
||||
|
@ -155,7 +158,7 @@ export default definePlugin({
|
|||
// Add back link context menu
|
||||
{
|
||||
find: '"interactionUsernameProfile"',
|
||||
predicate: () => settings.store.addBack,
|
||||
predicate: shouldAddBackMenus,
|
||||
replacement: {
|
||||
match: /if\((?="A"===\i\.tagName&&""!==\i\.textContent)/,
|
||||
replace: "if(false&&"
|
||||
|
@ -165,7 +168,7 @@ export default definePlugin({
|
|||
// Add back slate / text input context menu
|
||||
{
|
||||
find: 'getElementById("slate-toolbar"',
|
||||
predicate: () => settings.store.addBack,
|
||||
predicate: shouldAddBackMenus,
|
||||
replacement: {
|
||||
match: /(?<=handleContextMenu\(\i\)\{.{0,200}isPlatformEmbedded)\)/,
|
||||
replace: "||true)"
|
||||
|
@ -173,7 +176,7 @@ export default definePlugin({
|
|||
},
|
||||
{
|
||||
find: ".SLASH_COMMAND_SUGGESTIONS_TOGGLED,{",
|
||||
predicate: () => settings.store.addBack,
|
||||
predicate: shouldAddBackMenus,
|
||||
replacement: [
|
||||
{
|
||||
// if (!IS_DESKTOP) return null;
|
||||
|
@ -189,7 +192,7 @@ export default definePlugin({
|
|||
},
|
||||
{
|
||||
find: '"add-to-dictionary"',
|
||||
predicate: () => settings.store.addBack,
|
||||
predicate: shouldAddBackMenus,
|
||||
replacement: {
|
||||
match: /let\{text:\i=""/,
|
||||
replace: "return [null,null];$&"
|
||||
|
|
|
@ -23,6 +23,7 @@ export const DONOR_ROLE_ID = "1042507929485586532";
|
|||
export const CONTRIB_ROLE_ID = "1026534353167208489";
|
||||
export const REGULAR_ROLE_ID = "1026504932959977532";
|
||||
export const SUPPORT_CHANNEL_ID = "1026515880080842772";
|
||||
export const SUPPORT_CATEGORY_ID = "1108135649699180705";
|
||||
export const KNOWN_ISSUES_CHANNEL_ID = "1222936386626129920";
|
||||
|
||||
export interface Dev {
|
||||
|
|
Loading…
Add table
Reference in a new issue