mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-18 05:13:29 -05:00
Separate MoreKaomoji Commands
This commit is contained in:
parent
1d5d309a97
commit
fe5a18b429
3 changed files with 110 additions and 21 deletions
|
@ -23,7 +23,6 @@ import { normalize as posixNormalize, sep as posixSep } from "path/posix";
|
||||||
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, PropertyAssignment, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
|
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, PropertyAssignment, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
|
||||||
|
|
||||||
import { getPluginTarget } from "./utils.mjs";
|
import { getPluginTarget } from "./utils.mjs";
|
||||||
import { ApplicationCommandOptionType } from "@api/Commands";
|
|
||||||
|
|
||||||
interface Dev {
|
interface Dev {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { Dirent, readdirSync, readFileSync, writeFileSync } from "fs";
|
||||||
import { access, readFile } from "fs/promises";
|
import { access, readFile } from "fs/promises";
|
||||||
import { join, sep } from "path";
|
import { join, sep } from "path";
|
||||||
import { normalize as posixNormalize, sep as posixSep } from "path/posix";
|
import { normalize as posixNormalize, sep as posixSep } from "path/posix";
|
||||||
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
|
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, PropertyAssignment, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
|
||||||
|
|
||||||
import { getPluginTarget } from "./utils.mjs";
|
import { getPluginTarget } from "./utils.mjs";
|
||||||
|
|
||||||
|
@ -29,6 +29,11 @@ interface Dev {
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Command {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface PluginData {
|
interface PluginData {
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
@ -37,6 +42,7 @@ interface PluginData {
|
||||||
dependencies: string[];
|
dependencies: string[];
|
||||||
hasPatches: boolean;
|
hasPatches: boolean;
|
||||||
hasCommands: boolean;
|
hasCommands: boolean;
|
||||||
|
commands: Command[];
|
||||||
required: boolean;
|
required: boolean;
|
||||||
enabledByDefault: boolean;
|
enabledByDefault: boolean;
|
||||||
target: "discordDesktop" | "vencordDesktop" | "equicordDesktop" | "desktop" | "web" | "dev";
|
target: "discordDesktop" | "vencordDesktop" | "equicordDesktop" | "desktop" | "web" | "dev";
|
||||||
|
@ -161,6 +167,20 @@ async function parseFile(fileName: string) {
|
||||||
break;
|
break;
|
||||||
case "commands":
|
case "commands":
|
||||||
data.hasCommands = true;
|
data.hasCommands = true;
|
||||||
|
if (!isArrayLiteralExpression(value)) throw fail("commands is not an array literal");
|
||||||
|
data.commands = value.elements.map((e) => {
|
||||||
|
if (!isObjectLiteralExpression(e)) throw fail("commands array contains non-object literals");
|
||||||
|
const nameProperty = e.properties.find((p): p is PropertyAssignment => {
|
||||||
|
return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'name';
|
||||||
|
});
|
||||||
|
const descriptionProperty = e.properties.find((p): p is PropertyAssignment => {
|
||||||
|
return isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === 'description';
|
||||||
|
});
|
||||||
|
if (!nameProperty || !descriptionProperty) throw fail("Command missing required properties");
|
||||||
|
const name = isStringLiteral(nameProperty.initializer) ? nameProperty.initializer.text : '';
|
||||||
|
const description = isStringLiteral(descriptionProperty.initializer) ? descriptionProperty.initializer.text : '';
|
||||||
|
return { name, description };
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case "authors":
|
case "authors":
|
||||||
if (!isArrayLiteralExpression(value)) throw fail("authors is not an array literal");
|
if (!isArrayLiteralExpression(value)) throw fail("authors is not an array literal");
|
||||||
|
|
|
@ -25,23 +25,93 @@ export default definePlugin({
|
||||||
description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
|
description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
|
||||||
authors: [Devs.JacobTm],
|
authors: [Devs.JacobTm],
|
||||||
commands: [
|
commands: [
|
||||||
{ name: "dissatisfaction", description: " >﹏<" },
|
{
|
||||||
{ name: "smug", description: "ಠ_ಠ" },
|
name: "dissatisfaction",
|
||||||
{ name: "happy", description: "ヽ(´▽`)/" },
|
description: " >﹏<",
|
||||||
{ name: "crying", description: "ಥ_ಥ" },
|
options: [OptionalMessageOption],
|
||||||
{ name: "angry", description: "ヽ(`Д´)ノ" },
|
execute: opts => ({
|
||||||
{ name: "anger", description: "ヽ(o`皿′o)ノ" },
|
content: findOption(opts, "message", "") + " " + " >﹏<",
|
||||||
{ name: "joy", description: "<( ̄︶ ̄)>" },
|
}),
|
||||||
{ name: "blush", description: "૮ ˶ᵔ ᵕ ᵔ˶ ა" },
|
},
|
||||||
{ name: "confused", description: "(•ิ_•ิ)?" },
|
{
|
||||||
{ name: "sleeping", description: "(ᴗ_ᴗ)" },
|
name: "smug",
|
||||||
{ name: "laughing", description: "o(≧▽≦)o" },
|
description: "ಠ_ಠ",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
].map(data => ({
|
execute: opts => ({
|
||||||
...data,
|
content: findOption(opts, "message", "") + " " + "ಠ_ಠ",
|
||||||
options: [OptionalMessageOption],
|
}),
|
||||||
execute: opts => ({
|
},
|
||||||
content: findOption(opts, "message", "") + " " + data.description
|
{
|
||||||
})
|
name: "happy",
|
||||||
}))
|
description: "ヽ(´▽`)/",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
|
execute: opts => ({
|
||||||
|
content: findOption(opts, "message", "") + " " + "ヽ(´▽`)/",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "crying",
|
||||||
|
description: "ಥ_ಥ",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
|
execute: opts => ({
|
||||||
|
content: findOption(opts, "message", "") + " " + "ಥ_ಥ",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "angry",
|
||||||
|
description: "ヽ(`Д´)ノ",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
|
execute: opts => ({
|
||||||
|
content: findOption(opts, "message", "") + " " + "ヽ(`Д´)ノ",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "anger",
|
||||||
|
description: "ヽ(o`皿′o)ノ",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
|
execute: opts => ({
|
||||||
|
content: findOption(opts, "message", "") + " " + "ヽ(o`皿′o)ノ",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "joy",
|
||||||
|
description: "<( ̄︶ ̄)>",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
|
execute: opts => ({
|
||||||
|
content: findOption(opts, "message", "") + " " + "<( ̄︶ ̄)>",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "blush",
|
||||||
|
description: "૮ ˶ᵔ ᵕ ᵔ˶ ა",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
|
execute: opts => ({
|
||||||
|
content: findOption(opts, "message", "") + " " + "૮ ˶ᵔ ᵕ ᵔ˶ ა",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "confused",
|
||||||
|
description: "(•ิ_•ิ)?",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
|
execute: opts => ({
|
||||||
|
content: findOption(opts, "message", "") + " " + "(•ิ_•ิ)?",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "sleeping",
|
||||||
|
description: "(ᴗ_ᴗ)",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
|
execute: opts => ({
|
||||||
|
content: findOption(opts, "message", "") + " " + "(ᴗ_ᴗ)",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "laughing",
|
||||||
|
description: "o(≧▽≦)o",
|
||||||
|
options: [OptionalMessageOption],
|
||||||
|
execute: opts => ({
|
||||||
|
content: findOption(opts, "message", "") + " " + "o(≧▽≦)o",
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue