terry
This commit is contained in:
parent
ab612467cc
commit
cecdf21657
13 changed files with 65 additions and 96 deletions
|
@ -1,3 +1,5 @@
|
|||
DISCORD_ID=
|
||||
DISCORD_TOKEN=
|
||||
DISCORD_SECRET=
|
||||
|
||||
OLLAMA_API=
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -2,18 +2,15 @@ import { logger } from "@discordeno/utils";
|
|||
|
||||
import REST from "../src/lib/handlers/RESTHandler";
|
||||
import * as InteractionHandler from "../src/lib/handlers/InteractionHandler";
|
||||
import * as CommandHandler from "../src/lib/handlers/CommandHandler";
|
||||
await InteractionHandler.load();
|
||||
|
||||
const registered = await REST.getGlobalApplicationCommands();
|
||||
|
||||
for (let { id, name, type } of registered) {
|
||||
const cmd = CommandHandler.commands.get(name);
|
||||
if (cmd && cmd.type == type) continue;
|
||||
|
||||
const id = process.argv[2];
|
||||
const cmd = registered.find((_) => _.id === id);
|
||||
if (cmd) {
|
||||
await REST.deleteGlobalApplicationCommand(id);
|
||||
|
||||
logger.info(`Deleted ${name}(${id})`);
|
||||
logger.info(`Deleted ${cmd.name}(${id})`);
|
||||
}
|
||||
|
||||
process.exit();
|
||||
|
|
10
bin/list.js
10
bin/list.js
|
@ -5,16 +5,16 @@ const registered = await REST.getGlobalApplicationCommands();
|
|||
|
||||
const TYPES = ["CHAT_INPUT", "USER", "MESSAGE"];
|
||||
|
||||
logger.info("┌" + "-".repeat(58) + "┐");
|
||||
logger.info("| " + "ID".padEnd(24, " ") + " | " + "NAME".padEnd(16, " ") + " | " + "TYPE".padEnd(10, " ") + " |");
|
||||
logger.info("├" + "-".repeat(58) + "┤");
|
||||
logger.info("┌" + "-".repeat(58 + 8) + "┐");
|
||||
logger.info("| " + "ID".padEnd(24, " ") + " | " + "NAME".padEnd(24, " ") + " | " + "TYPE".padEnd(10, " ") + " |");
|
||||
logger.info("├" + "-".repeat(58 + 8) + "┤");
|
||||
|
||||
for (let { id, name, type } of registered) {
|
||||
logger.info(
|
||||
"| " + id.padEnd(24, " ") + " | " + name.padEnd(16, " ") + " | " + TYPES[type - 1].padEnd(10, " ") + " |",
|
||||
"| " + id.padEnd(24, " ") + " | " + name.padEnd(24, " ") + " | " + TYPES[type - 1].padEnd(10, " ") + " |",
|
||||
);
|
||||
}
|
||||
|
||||
logger.info("└" + "-".repeat(58) + "┘");
|
||||
logger.info("└" + "-".repeat(58 + 8) + "┘");
|
||||
|
||||
process.exit();
|
||||
|
|
|
@ -11,7 +11,7 @@ for (let [key, value] of CommandHandler.commands.entries()) {
|
|||
headers: { "Content-Type": "application/json", Authorization: "Bot " + process.env.DISCORD_TOKEN },
|
||||
body: JSON.stringify({
|
||||
name: value.name,
|
||||
type: value.type,
|
||||
type: value.commandType,
|
||||
description: value?.description || "",
|
||||
options: value?.options,
|
||||
nsfw: value?.nsfw,
|
||||
|
@ -21,8 +21,11 @@ for (let [key, value] of CommandHandler.commands.entries()) {
|
|||
});
|
||||
|
||||
const command = await response.json();
|
||||
|
||||
logger.info(`Registered ${command.name}(${command.id})`);
|
||||
if (command.id) logger.info(`Registered ${command.name}(${command.id})(type:${value.type})`);
|
||||
else {
|
||||
logger.error(`Failed to register new command ${value.name}(type:${value.type})`);
|
||||
console.log(JSON.stringify(command.errors, null, 4));
|
||||
}
|
||||
}
|
||||
|
||||
process.exit();
|
||||
|
|
20
src/interactions/bizz.ts
Normal file
20
src/interactions/bizz.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import type { Command } from "../lib/types/command";
|
||||
import { InteractionResponseTypes } from "@discordeno/bot";
|
||||
import UserCommand from "../lib/classes/UserCommand";
|
||||
|
||||
export default class extends UserCommand implements Command {
|
||||
name = "Bizz";
|
||||
description = "";
|
||||
options = [];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
async run() {
|
||||
return {
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
data: { content: "<:FvU757MaYAAb_G9:1265558339283320864>" },
|
||||
};
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@ import { InteractionResponseTypes } from "@discordeno/bot";
|
|||
import SlashCommand from "../lib/classes/SlashCommand";
|
||||
|
||||
export default class extends SlashCommand implements Command {
|
||||
name = "default";
|
||||
description = "default";
|
||||
name = "foo";
|
||||
description = "Foo";
|
||||
options = [];
|
||||
|
||||
constructor() {
|
||||
|
@ -14,7 +14,7 @@ export default class extends SlashCommand implements Command {
|
|||
async run() {
|
||||
return {
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
data: { content: "my name is terry and im going to destroy thgis world" },
|
||||
data: { content: "Bar" },
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
import type { Command } from "../lib/types/command";
|
||||
import { MessageComponentTypes, TextStyles } from "@discordeno/bot";
|
||||
import SlashCommand from "../lib/classes/SlashCommand";
|
||||
import Modal from "../lib/classes/Modal";
|
||||
import { collectModal } from "../lib/handlers/ModalHandler";
|
||||
|
||||
interface SendMailResponse {
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export default class extends SlashCommand implements Command {
|
||||
name = "send";
|
||||
description = "Send mail to a user in the Enigmatica 9 server!";
|
||||
options = [];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
async run() {
|
||||
const modal = new Modal().setTitle("Send Mail").setComponents([
|
||||
{
|
||||
type: MessageComponentTypes.ActionRow,
|
||||
components: [
|
||||
{
|
||||
type: MessageComponentTypes.InputText,
|
||||
customId: "recipient",
|
||||
style: TextStyles.Short,
|
||||
label: "Recipient",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: MessageComponentTypes.ActionRow,
|
||||
components: [
|
||||
{
|
||||
type: MessageComponentTypes.InputText,
|
||||
customId: "content",
|
||||
style: TextStyles.Paragraph,
|
||||
label: "Message",
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
collectModal(modal)
|
||||
.then(async ({ interaction, values }) => {
|
||||
if (!interaction.data?.components) return;
|
||||
const user = interaction?.member?.user || { username: "[unknown]" };
|
||||
|
||||
try {
|
||||
const response = await fetch(process.env.MAIL_SERVER + "/send", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
author: user.username,
|
||||
recipient: values.get("recipient"),
|
||||
content: values.get("content"),
|
||||
}),
|
||||
});
|
||||
|
||||
const body = (await response.json()) as SendMailResponse;
|
||||
interaction.respond(body.message);
|
||||
} catch (e) {
|
||||
return interaction.respond((e as Error).message);
|
||||
}
|
||||
})
|
||||
.catch((_) => {});
|
||||
|
||||
return modal;
|
||||
}
|
||||
}
|
20
src/interactions/upload.ts
Normal file
20
src/interactions/upload.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import type { Command } from "../lib/types/command";
|
||||
import { InteractionResponseTypes } from "@discordeno/bot";
|
||||
import MessageCommand from "../lib/classes/MessageCommand";
|
||||
|
||||
export default class extends MessageCommand implements Command {
|
||||
name = "Upload to snep.lol";
|
||||
description = "";
|
||||
options = [];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
async run() {
|
||||
return {
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
data: { content: "MY NUTS LMAO" },
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { InteractionTypes } from "@discordeno/types";
|
||||
|
||||
export default class ApplicationCommand {
|
||||
static type = InteractionTypes.ApplicationCommand;
|
||||
type = InteractionTypes.ApplicationCommand;
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@ import { ApplicationCommandTypes } from "@discordeno/types";
|
|||
import ApplicationCommand from "./ApplicationCommand";
|
||||
|
||||
export default class SlashCommand extends ApplicationCommand {
|
||||
static commandType = ApplicationCommandTypes.Message;
|
||||
commandType = ApplicationCommandTypes.Message;
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@ import { ApplicationCommandTypes } from "@discordeno/types";
|
|||
import ApplicationCommand from "./ApplicationCommand";
|
||||
|
||||
export default class SlashCommand extends ApplicationCommand {
|
||||
static commandType = ApplicationCommandTypes.ChatInput;
|
||||
commandType = ApplicationCommandTypes.ChatInput;
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@ import { ApplicationCommandTypes } from "@discordeno/types";
|
|||
import ApplicationCommand from "./ApplicationCommand";
|
||||
|
||||
export default class SlashCommand extends ApplicationCommand {
|
||||
static commandType = ApplicationCommandTypes.User;
|
||||
commandType = ApplicationCommandTypes.User;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue