mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-18 21:33:35 -05:00
Womp Womp
This commit is contained in:
parent
353caf04e1
commit
36131de800
1 changed files with 26 additions and 3 deletions
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { addAccessory } from "@api/MessageAccessories";
|
import { addAccessory } from "@api/MessageAccessories";
|
||||||
|
import { MessageObject } from "@api/MessageEvents";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { getUserSettingLazy } from "@api/UserSettings";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
@ -24,10 +25,10 @@ import { Flex } from "@components/Flex";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab";
|
import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab";
|
||||||
import { Devs, EquicordDevs, SUPPORT_CHANNEL_ID, SUPPORT_CHANNEL_IDS, VC_SUPPORT_CHANNEL_ID } from "@utils/constants";
|
import { Devs, EquicordDevs, SUPPORT_CHANNEL_ID, SUPPORT_CHANNEL_IDS, VC_SUPPORT_CHANNEL_ID } from "@utils/constants";
|
||||||
import { sendMessage } from "@utils/discord";
|
import { getCurrentChannel, sendMessage } from "@utils/discord";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { isEquicordPluginDev, isPluginDev, tryOrElse } from "@utils/misc";
|
import { isEquicordPluginDev, isPluginDev, sleep, tryOrElse } from "@utils/misc";
|
||||||
import { relaunch } from "@utils/native";
|
import { relaunch } from "@utils/native";
|
||||||
import { onlyOnce } from "@utils/onlyOnce";
|
import { onlyOnce } from "@utils/onlyOnce";
|
||||||
import { makeCodeblock } from "@utils/text";
|
import { makeCodeblock } from "@utils/text";
|
||||||
|
@ -135,6 +136,26 @@ function generatePluginList() {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function intoChunks(): string[] {
|
||||||
|
const messageContent: string = generatePluginList();
|
||||||
|
if (messageContent.length <= 2000) return [messageContent];
|
||||||
|
|
||||||
|
let chunks: string[] = [];
|
||||||
|
for (let idx = 0; idx < messageContent.length; idx += 2000) {
|
||||||
|
chunks.push(messageContent.slice(idx, idx + 2000));
|
||||||
|
}
|
||||||
|
chunks = chunks.map(e => e.trimStart().trimEnd());
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendMessages(channelId: string, messageContents: string[], delay: number) {
|
||||||
|
for (const messageContent of messageContents) {
|
||||||
|
const messageObject: Partial<MessageObject> = { content: messageContent };
|
||||||
|
sendMessage(channelId, messageObject);
|
||||||
|
await sleep(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const checkForUpdatesOnce = onlyOnce(checkForUpdates);
|
const checkForUpdatesOnce = onlyOnce(checkForUpdates);
|
||||||
|
|
||||||
const settings = definePluginSettings({}).withPrivateSettings<{
|
const settings = definePluginSettings({}).withPrivateSettings<{
|
||||||
|
@ -171,7 +192,9 @@ export default definePlugin({
|
||||||
name: "equicord-plugins",
|
name: "equicord-plugins",
|
||||||
description: "Send Equicord plugin list",
|
description: "Send Equicord plugin list",
|
||||||
predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || isEquicordPluginDev(UserStore.getCurrentUser()?.id) || AllowedChannelIds.includes(ctx.channel.id),
|
predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || isEquicordPluginDev(UserStore.getCurrentUser()?.id) || AllowedChannelIds.includes(ctx.channel.id),
|
||||||
execute: () => ({ content: generatePluginList() })
|
execute: (_, ctx) => {
|
||||||
|
sendMessages(ctx.channel.id, intoChunks(), Math.max(2000, getCurrentChannel().rateLimitPerUser ?? 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue