This commit is contained in:
thororen1234 2025-06-19 18:18:53 -04:00
parent f4380447ed
commit 654cdc2f75
No known key found for this signature in database
3 changed files with 320 additions and 120 deletions

View file

@ -200,45 +200,50 @@ export default definePlugin({
inputType: ApplicationCommandInputType.BUILT_IN, inputType: ApplicationCommandInputType.BUILT_IN,
name: "download", name: "download",
description: "Download and send videos, audio or gifs.", description: "Download and send videos, audio or gifs.",
options: [{ options: [
name: "url", {
description: "The URL of any video supported by yt-dlp.", name: "url",
required: true, description: "The URL of any video supported by yt-dlp.",
type: ApplicationCommandOptionType.STRING required: true,
}, { type: ApplicationCommandOptionType.STRING
name: "format", },
description: "Whether to download a video or audio.", {
type: ApplicationCommandOptionType.STRING, name: "format",
choices: [ description: "Whether to download a video or audio.",
{ name: "Video", value: "video", label: "Video" }, type: ApplicationCommandOptionType.STRING,
{ name: "Audio", value: "audio", label: "Audio" }, choices: [
{ name: "GIF", value: "gif", label: "GIF" } { name: "Video", value: "video", label: "Video" },
], { name: "Audio", value: "audio", label: "Audio" },
required: false, { name: "GIF", value: "gif", label: "GIF" }
}, { ],
name: "gif_quality", required: false,
type: ApplicationCommandOptionType.INTEGER, },
description: "The quality level when using GIF. Try lowering this number if the GIF is too large.", {
required: false, name: "gif_quality",
choices: [ type: ApplicationCommandOptionType.INTEGER,
{ name: "5", value: "5", label: "5" }, description: "The quality level when using GIF. Try lowering this number if the GIF is too large.",
{ name: "4", value: "4", label: "4" }, required: false,
{ name: "3", value: "3", label: "3" }, choices: [
{ name: "2", value: "2", label: "2" }, { name: "5", value: "5", label: "5" },
{ name: "1", value: "1", label: "1" } { name: "4", value: "4", label: "4" },
] { name: "3", value: "3", label: "3" },
}, { { name: "2", value: "2", label: "2" },
name: "yt-dlp_args", { name: "1", value: "1", label: "1" }
description: "Additional arguments to pass to yt-dlp. These will take precedence over arguments set in the settings. This may overwrite default plugin arguments such format selection. Note: if modifying the output, ensure the filename starts with `download`.", ]
required: false, },
type: ApplicationCommandOptionType.STRING {
}, { name: "yt-dlp_args",
name: "ffmpeg_args", description: "Additional arguments to pass to yt-dlp. These will take precedence over arguments set in the settings. This may overwrite default plugin arguments such format selection. Note: if modifying the output, ensure the filename starts with `download`.",
description: "Additional arguments to pass to ffmpeg. These will take precedence over arguments set in the settings. This may overwrite default plugin arguments such as auto-scaling. Note: if modifying the output, ensure the filename starts with `remux`.", required: false,
required: false, type: ApplicationCommandOptionType.STRING
type: ApplicationCommandOptionType.STRING },
}], {
name: "ffmpeg_args",
description: "Additional arguments to pass to ffmpeg. These will take precedence over arguments set in the settings. This may overwrite default plugin arguments such as auto-scaling. Note: if modifying the output, ensure the filename starts with `remux`.",
required: false,
type: ApplicationCommandOptionType.STRING
}
],
execute: async (args, ctx) => { execute: async (args, ctx) => {
if (!await Native.isYtdlpAvailable()) return openDependencyModal(); if (!await Native.isYtdlpAvailable()) return openDependencyModal();
if (!await Native.isFfmpegAvailable() && settings.store.showFfmpegWarning) sendFfmpegWarning(ctx.channel.id); if (!await Native.isFfmpegAvailable() && settings.store.showFfmpegWarning) sendFfmpegWarning(ctx.channel.id);

View file

@ -31,7 +31,7 @@ function mock(input: string): string {
export default definePlugin({ export default definePlugin({
name: "MoreCommands", name: "MoreCommands",
description: "echo, lenny, mock", description: "Echo, Lenny, Mock, and More",
authors: [Devs.Arjix, Devs.echo, Devs.Samu, EquicordDevs.zyqunix], authors: [Devs.Arjix, Devs.echo, Devs.Samu, EquicordDevs.zyqunix],
commands: [ commands: [
{ {
@ -62,112 +62,308 @@ export default definePlugin({
}), }),
}, },
{ {
name: "toLowerCase", name: "wordcount",
description: "all text will be lowercase", description: "Counts the number of words in a message",
options: [ options: [RequiredMessageOption],
{ inputType: ApplicationCommandInputType.BOT,
name: "text", execute: (opts, ctx) => {
description: "text to lowercase", const message = findOption(opts, "message", "");
type: ApplicationCommandOptionType.STRING, const wordCount = message.trim().split(/\s+/).length;
required: true sendBotMessage(ctx.channel.id, {
} content: `The message contains ${wordCount} words.`
], });
execute: opts => {
const input = opts.find(o => o.name === "text")?.value as string;
const content = input.toLowerCase();
return { content: content };
}, },
}, },
{ {
name: "toUpperCase", name: "ping",
description: "ALL TEXT WILL BE UPPERCASE", description: "Pings the bot to check if it's responding",
options: [ options: [],
{ inputType: ApplicationCommandInputType.BOT,
name: "text", execute: (opts, ctx) => {
description: "TEXT TO UPPERCASE", sendBotMessage(ctx.channel.id, {
type: ApplicationCommandOptionType.STRING, content: "Pong!"
required: true });
}
],
execute: opts => {
const input = opts.find(o => o.name === "text")?.value as string;
const content = input.toUpperCase();
return { content: content };
}, },
}, },
{ {
name: "toLocaleLowerCase", name: "rolldice",
description: "all text will be locale lowercase", description: "Roll a die with the specified number of sides",
options: [ options: [RequiredMessageOption],
{
name: "text",
description: "text to lowercase",
type: ApplicationCommandOptionType.STRING,
required: true
}
],
execute: opts => { execute: opts => {
const input = opts.find(o => o.name === "text")?.value as string; const sides = parseInt(findOption(opts, "message", "6"));
const content = input.toLocaleLowerCase(); const roll = Math.floor(Math.random() * sides) + 1;
return { content: content }; return {
content: `You rolled a ${roll}!`
};
}, },
}, },
{ {
name: "toLocaleUpperCase", name: "flipcoin",
description: "ALL TEXT WILL BE LOCALE UPPERCASE", description: "Flips a coin and returns heads or tails",
options: [ options: [],
{ execute: (opts, ctx) => {
name: "text", const flip = Math.random() < 0.5 ? "Heads" : "Tails";
description: "TEXT TO UPPERCASE", return {
type: ApplicationCommandOptionType.STRING, content: `The coin landed on: ${flip}`
required: true };
}
],
execute: opts => {
const input = opts.find(o => o.name === "text")?.value as string;
const content = input.toLocaleUpperCase();
return { content: content };
}, },
}, },
{ {
name: "normalize", name: "ask",
description: "Returns Unicode Normalization Form of string", description: "Ask a yes/no question and get an answer",
options: [ options: [RequiredMessageOption],
{
name: "text",
description: "Text to normalize",
type: ApplicationCommandOptionType.STRING,
required: true
}
],
execute: opts => { execute: opts => {
const input = opts.find(o => o.name === "text")?.value as string; const question = findOption(opts, "message", "");
const content = input.normalize(); const responses = ["Yes", "No", "Maybe", "Ask again later", "Definitely not", "It is certain"];
return { content: content }; const response = responses[Math.floor(Math.random() * responses.length)];
return {
content: `${question} - ${response}`
};
}, },
}, },
{ {
name: "repeat", name: "randomanimal",
description: "Repeats the string count times", description: "Get a random cat picture",
options: [ options: [
{ {
name: "text", name: "animal",
description: "Text to repeat", description: "pick your animal",
type: ApplicationCommandOptionType.STRING, type: ApplicationCommandOptionType.STRING,
required: true,
choices: [
{ name: "cat", value: "cat", label: "cat" },
{ name: "dog", value: "dog", label: "dog" },
]
}
],
execute: (opts, ctx) => {
return (async () => {
const animal = findOption(opts, "animal") as string;
let url;
if (animal === "cat") {
url = "https://api.thecatapi.com/v1/images/search";
} else if (animal === "dog") {
url = "https://api.thedogapi.com/v1/images/search";
}
try {
const response = await fetch(url);
if (!response.ok) throw new Error(`Failed to fetch ${animal} image`);
const data = await response.json();
return {
content: data[0].url
};
} catch (err) {
sendBotMessage(ctx.channel.id, {
content: "Sorry, couldn't fetch a cat picture right now 😿"
});
}
})();
},
},
{
name: "randomnumber",
description: "Generates a random number between two values",
options: [
{
name: "min",
description: "Minimum value",
type: ApplicationCommandOptionType.INTEGER,
required: true required: true
}, },
{ {
name: "count", name: "max",
description: "Amount of repetitions", description: "Maximum value",
type: ApplicationCommandOptionType.INTEGER, type: ApplicationCommandOptionType.INTEGER,
required: true required: true
} }
], ],
execute: opts => { execute: opts => {
const text = opts.find(o => o.name === "text")?.value as string; const min = parseInt(findOption(opts, "min", "0"));
const count = (opts.find(o => o.name === "count")?.value ?? 1) as number; const max = parseInt(findOption(opts, "max", "100"));
const content = text.repeat(count); const number = Math.floor(Math.random() * (max - min + 1)) + min;
return { content: content }; return {
content: `Random number between ${min} and ${max}: ${number}`
};
}
},
{
name: "countdown",
description: "Starts a countdown from a specified number",
options: [
{
name: "number",
description: "Number to countdown from (max 10)",
type: ApplicationCommandOptionType.INTEGER,
required: true
}
],
inputType: ApplicationCommandInputType.BOT,
execute: async (opts, ctx) => {
const number = Math.min(parseInt(findOption(opts, "number", "5")), 10);
if (isNaN(number) || number < 1) {
sendBotMessage(ctx.channel.id, {
content: "Please provide a valid number between 1 and 10!"
});
return;
}
sendBotMessage(ctx.channel.id, {
content: `Starting countdown from ${number}...`
});
for (let i = number; i >= 0; i--) {
await new Promise(resolve => setTimeout(resolve, 1000));
sendBotMessage(ctx.channel.id, {
content: i === 0 ? "🎉 Go! 🎉" : `${i}...`
});
}
},
},
{
name: "choose",
description: "Randomly chooses from provided options",
options: [
{
name: "choices",
description: "Comma-separated list of choices",
type: ApplicationCommandOptionType.STRING,
required: true
}
],
execute: opts => {
const choices = findOption(opts, "choices", "").split(",").map(c => c.trim());
const choice = choices[Math.floor(Math.random() * choices.length)];
return {
content: `I choose: ${choice}`
};
}
},
{
name: "systeminfo",
description: "Shows system information",
options: [],
execute: async (opts, ctx) => {
try {
const { userAgent, hardwareConcurrency, onLine, languages } = navigator;
const { width, height, colorDepth } = window.screen;
const { deviceMemory, connection }: { deviceMemory: any, connection: any; } = navigator as any;
const platform = userAgent.includes("Windows") ? "Windows" :
userAgent.includes("Mac") ? "MacOS" :
userAgent.includes("Linux") ? "Linux" : "Unknown";
const isMobile = /Mobile|Android|iPhone/i.test(userAgent);
const deviceType = isMobile ? "Mobile" : "Desktop";
const browserInfo = userAgent.match(/(?:chrome|firefox|safari|edge|opr)\/?\s*(\d+)/i)?.[0] || "Unknown";
const networkInfo = connection ? `${connection.effectiveType || "Unknown"}` : "Unknown";
const info = [
`> **Platform**: ${platform}`,
`> **Device Type**: ${deviceType}`,
`> **Browser**: ${browserInfo}`,
`> **CPU Cores**: ${hardwareConcurrency || "N/A"}`,
`> **Memory**: ${deviceMemory ? `${deviceMemory}GB` : "N/A"}`,
`> **Screen**: ${width}x${height} (${colorDepth}bit)`,
`> **Languages**: ${languages?.join(", ")}`,
`> **Network**: ${networkInfo} (${onLine ? "Online" : "Offline"})`
].join("\n");
return { content: info };
} catch (err) {
sendBotMessage(ctx.channel.id, { content: "Failed to fetch system information" });
}
},
},
{
name: "getUptime",
description: "Returns the system uptime",
execute: async (opts, ctx) => {
const uptime = performance.now() / 1000;
const uptimeInfo = `> **System Uptime**: ${Math.floor(uptime / 60)} minutes`;
return { content: uptimeInfo };
},
},
{
name: "getTime",
description: "Returns the current server time",
execute: async (opts, ctx) => {
const currentTime = new Date().toLocaleString();
return { content: `> **Current Time**: ${currentTime}` };
},
},
{
name: "getLocation",
description: "Returns the user's approximate location based on IP",
execute: async (opts, ctx) => {
try {
const response = await fetch("https://ipapi.co/json/");
const data = await response.json();
const locationInfo = `> **Country**: ${data.country_name}\n> **Region**: ${data.region}\n> **City**: ${data.city}`;
return { content: locationInfo };
} catch (err) {
sendBotMessage(ctx.channel.id, { content: "Failed to fetch location information" });
}
},
},
{
name: "transform",
description: "Transform your text with the specified option",
options: [
{
name: "text",
description: "TEXT TO UPPERCASE",
type: ApplicationCommandOptionType.STRING,
required: true
},
{
name: "transformation",
description: "transformation to apply to your text",
type: ApplicationCommandOptionType.STRING,
required: true,
choices: [
{ name: "toLowerCase", value: "toLowerCase", label: "toLowerCase" },
{ name: "toUpperCase", value: "toUpperCase", label: "toUpperCase" },
{ name: "toLocaleLowerCase", value: "toLocaleLowerCase", label: "toLocaleLowerCase" },
{ name: "toLocaleUpperCase", value: "toLocaleUpperCase", label: "toLocaleUpperCase" },
{ name: "reverse", value: "reverse", label: "reverse" },
{ name: "stay the same", value: "same", label: "stay the same" }
]
},
{
name: "repeat",
description: "how many times to repeat",
type: ApplicationCommandOptionType.INTEGER,
required: false
},
{
name: "normalize",
description: "which normailze option to use",
type: ApplicationCommandOptionType.INTEGER,
required: false,
choices: [
{ name: "NFC", value: "NFC", label: "NFC" },
{ name: "NFD", value: "NFD", label: "NFD" },
{ name: "NFKC", value: "NFKC", label: "NFKC" },
{ name: "NFKD", value: "NFKD", label: "NFKD" }
]
},
],
execute: opts => {
const transform = findOption(opts, "transformation") as string;
const repeat = findOption(opts, "repeat") as number | undefined;
const normalize = findOption(opts, "normalize") as string | undefined;
let text = findOption(opts, "text") as string;
if (transform && text) {
if (transform === "same") {
if (normalize) text = text.normalize(normalize);
return {
content: text.repeat(repeat ?? 1)
};
} else {
const method = (text as any)[transform];
const transformed = method.call(text);
if (normalize) text = text.normalize(normalize);
if (transform === "reverse") text = text.split("").reverse().join("");
return {
content: transformed.repeat(repeat ?? 1)
};
}
}
}, },
}, },
] ]

View file

@ -21,7 +21,7 @@ import "./style.css";
import { definePluginSettings } from "@api/Settings"; import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; import { findByPropsLazy, findStoreLazy } from "@webpack";
import { FluxDispatcher } from "@webpack/common"; import { FluxDispatcher } from "@webpack/common";
import { ReactNode } from "react"; import { ReactNode } from "react";
@ -35,7 +35,6 @@ enum FolderIconDisplay {
export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore"); export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore");
const SortedGuildStore = findStoreLazy("SortedGuildStore"); const SortedGuildStore = findStoreLazy("SortedGuildStore");
const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand"); const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand");
let lastGuildId = null as string | null; let lastGuildId = null as string | null;