Found fix?
This commit is contained in:
parent
f2216b0dcf
commit
03b4f1070b
1 changed files with 57 additions and 36 deletions
|
|
@ -3,31 +3,60 @@ import { themes } from "@vendetta/themes";
|
||||||
import { plugins } from "@vendetta/plugins";
|
import { plugins } from "@vendetta/plugins";
|
||||||
import { storage } from "@vendetta/plugin";
|
import { storage } from "@vendetta/plugin";
|
||||||
import { alerts } from "@vendetta/ui";
|
import { alerts } from "@vendetta/ui";
|
||||||
import { validateChannelForCommand } from "../utils/messages";
|
|
||||||
|
|
||||||
import {
|
// Define constants directly since ../consts doesn't exist
|
||||||
ALERT,
|
const ALERT = {
|
||||||
ARGS,
|
CONTENT: "This list is over 2000 characters. Send anyway?",
|
||||||
EMPTY,
|
CONFIRM: "Send",
|
||||||
FAILED_TO_SEND_LIST,
|
CANCEL: "Cancel"
|
||||||
JOINERS,
|
};
|
||||||
NOTHING_TO_SEE,
|
|
||||||
SPLIT_LARGE_MESSAGES_PLUGIN,
|
const ARGS = {
|
||||||
STATUS
|
DETAILED: "detailed"
|
||||||
} from "../consts";
|
};
|
||||||
|
|
||||||
|
const EMPTY = "";
|
||||||
|
|
||||||
|
const FAILED_TO_SEND_LIST = {
|
||||||
|
SLM_NOT_INSTALLED: "This list is over 2000 characters. Install the Split Large Messages plugin to send it.",
|
||||||
|
SLM_NOT_ENABLED: "This list is over 2000 characters. Enable the Split Large Messages plugin to send it."
|
||||||
|
};
|
||||||
|
|
||||||
|
const JOINERS = {
|
||||||
|
SEMICOL: "; ",
|
||||||
|
NEW_LINE: "\n"
|
||||||
|
};
|
||||||
|
|
||||||
|
const NOTHING_TO_SEE = "Nothing to see here, huh...";
|
||||||
|
|
||||||
|
const SPLIT_LARGE_MESSAGES_PLUGIN = "github.com/fres621/vendetta-plugins";
|
||||||
|
|
||||||
|
const STATUS = {
|
||||||
|
ENABLED: "✅",
|
||||||
|
DISABLED: "❌",
|
||||||
|
SELECTED: "✅",
|
||||||
|
NOT_SELECTED: "❌"
|
||||||
|
};
|
||||||
|
|
||||||
const MessageActions = findByProps('sendMessage', 'receiveMessage');
|
const MessageActions = findByProps('sendMessage', 'receiveMessage');
|
||||||
const Clyde = findByProps('sendBotMessage');
|
const Clyde = findByProps('sendBotMessage');
|
||||||
|
|
||||||
const maxMessageLength = findByStoreName('UserStore')
|
const maxMessageLength = (() => {
|
||||||
.getCurrentUser()
|
try {
|
||||||
?.premiumType === 2
|
return findByStoreName('UserStore')
|
||||||
? 4000
|
.getCurrentUser()
|
||||||
: 2000;
|
?.premiumType === 2
|
||||||
|
? 4000
|
||||||
|
: 2000;
|
||||||
|
} catch (e) {
|
||||||
|
return 2000; // fallback
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
const isSLMPluginInstalled = (installedPlugins: typeof plugins) =>
|
const isSLMPluginInstalled = (installedPlugins: typeof plugins) =>
|
||||||
Object.keys(installedPlugins)
|
Object.keys(installedPlugins)
|
||||||
.includes(SPLIT_LARGE_MESSAGES_PLUGIN);
|
.includes(SPLIT_LARGE_MESSAGES_PLUGIN);
|
||||||
|
|
||||||
const isSLMPluginEnabled = (installedPlugins: typeof plugins) =>
|
const isSLMPluginEnabled = (installedPlugins: typeof plugins) =>
|
||||||
Object.values(installedPlugins)
|
Object.values(installedPlugins)
|
||||||
.find((plugin) => plugin.id == SPLIT_LARGE_MESSAGES_PLUGIN)
|
.find((plugin) => plugin.id == SPLIT_LARGE_MESSAGES_PLUGIN)
|
||||||
|
|
@ -59,12 +88,10 @@ const formatList = (list: string[]) =>
|
||||||
const getListLength = (list: string[]) => formatList(list).length;
|
const getListLength = (list: string[]) => formatList(list).length;
|
||||||
|
|
||||||
const sendList = async (channelID: string, list: string[]) => {
|
const sendList = async (channelID: string, list: string[]) => {
|
||||||
// Use consistent nonce generation
|
const fixNonce = Date.now().toString();
|
||||||
const nonce = (BigInt(Date.now()) * BigInt(4194304) + BigInt(Math.floor(Math.random() * 4194304))).toString();
|
|
||||||
|
|
||||||
await MessageActions.sendMessage(channelID, {
|
await MessageActions.sendMessage(channelID, {
|
||||||
content: formatList(list)
|
content: formatList(list)
|
||||||
}, void 0, { nonce });
|
}, void 0, { nonce: fixNonce });
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseListHeader = (type: 'Plugin' | 'Theme', length: number) => [
|
const baseListHeader = (type: 'Plugin' | 'Theme', length: number) => [
|
||||||
|
|
@ -72,10 +99,7 @@ const baseListHeader = (type: 'Plugin' | 'Theme', length: number) => [
|
||||||
EMPTY
|
EMPTY
|
||||||
];
|
];
|
||||||
|
|
||||||
export async function themeList(args: any[], ctx: CommandContext) {
|
export async function themeList(args: any[], ctx: any) {
|
||||||
const channelValidation = validateChannelForCommand(ctx);
|
|
||||||
if (channelValidation) return channelValidation;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const detailed = getArgumentValue(args);
|
const detailed = getArgumentValue(args);
|
||||||
const alwaysDetailed = storage.themeListAlwaysDetailed ?? false;
|
const alwaysDetailed = storage.themeListAlwaysDetailed ?? false;
|
||||||
|
|
@ -142,10 +166,7 @@ export async function themeList(args: any[], ctx: CommandContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function pluginList(args: any[], ctx: CommandContext) {
|
export async function pluginList(args: any[], ctx: any) {
|
||||||
const channelValidation = validateChannelForCommand(ctx);
|
|
||||||
if (channelValidation) return channelValidation;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const detailed = getArgumentValue(args);
|
const detailed = getArgumentValue(args);
|
||||||
const alwaysDetailed = storage.pluginListAlwaysDetailed ?? false;
|
const alwaysDetailed = storage.pluginListAlwaysDetailed ?? false;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue