Eliminated Discordeno, functional and runnable.
This commit is contained in:
72
deno.lock
generated
72
deno.lock
generated
@@ -1,40 +1,23 @@
|
|||||||
{
|
{
|
||||||
"version": "4",
|
"version": "4",
|
||||||
"specifiers": {
|
"specifiers": {
|
||||||
"jsr:@melvdouc/xml-parser@*": "0.1.1",
|
|
||||||
"jsr:@melvdouc/xml-parser@~0.1.1": "0.1.1",
|
|
||||||
"jsr:@std/assert@1": "1.0.12",
|
|
||||||
"jsr:@std/dotenv@0.225.3": "0.225.3",
|
"jsr:@std/dotenv@0.225.3": "0.225.3",
|
||||||
"jsr:@std/fmt@^1.0.5": "1.0.6",
|
"jsr:@std/fmt@^1.0.5": "1.0.6",
|
||||||
"jsr:@std/fs@^1.0.11": "1.0.16",
|
"jsr:@std/fs@^1.0.11": "1.0.15",
|
||||||
"jsr:@std/internal@^1.0.6": "1.0.6",
|
|
||||||
"jsr:@std/io@~0.225.2": "0.225.2",
|
"jsr:@std/io@~0.225.2": "0.225.2",
|
||||||
"jsr:@std/log@*": "0.224.14",
|
"jsr:@std/log@*": "0.224.14",
|
||||||
"npm:@types/node@^22.14.1": "22.14.1",
|
"npm:@types/node@^22.14.1": "22.14.1",
|
||||||
"npm:discord.js@14.18.0": "14.18.0",
|
"npm:discord.js@14.18.0": "14.18.0"
|
||||||
"npm:discordeno@21.0.0": "21.0.0"
|
|
||||||
},
|
},
|
||||||
"jsr": {
|
"jsr": {
|
||||||
"@melvdouc/xml-parser@0.1.1": {
|
|
||||||
"integrity": "5c79d37c6471cb74efb344988317270b57b4f181decb873e441453db42eb6e5f"
|
|
||||||
},
|
|
||||||
"@std/assert@1.0.12": {
|
|
||||||
"integrity": "08009f0926dda9cbd8bef3a35d3b6a4b964b0ab5c3e140a4e0351fbf34af5b9a",
|
|
||||||
"dependencies": [
|
|
||||||
"jsr:@std/internal"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"@std/dotenv@0.225.3": {
|
"@std/dotenv@0.225.3": {
|
||||||
"integrity": "a95e5b812c27b0854c52acbae215856d9cce9d4bbf774d938c51d212711e8d4a"
|
"integrity": "a95e5b812c27b0854c52acbae215856d9cce9d4bbf774d938c51d212711e8d4a"
|
||||||
},
|
},
|
||||||
"@std/fmt@1.0.6": {
|
"@std/fmt@1.0.6": {
|
||||||
"integrity": "a2c56a69a2369876ddb3ad6a500bb6501b5bad47bb3ea16bfb0c18974d2661fc"
|
"integrity": "a2c56a69a2369876ddb3ad6a500bb6501b5bad47bb3ea16bfb0c18974d2661fc"
|
||||||
},
|
},
|
||||||
"@std/fs@1.0.16": {
|
"@std/fs@1.0.15": {
|
||||||
"integrity": "81878f62b6eeda0bf546197fc3daa5327c132fee1273f6113f940784a468b036"
|
"integrity": "c083fb479889d6440d768e498195c3fc499d426fbf9a6592f98f53884d1d3f41"
|
||||||
},
|
|
||||||
"@std/internal@1.0.6": {
|
|
||||||
"integrity": "9533b128f230f73bd209408bb07a4b12f8d4255ab2a4d22a1fd6d87304aca9a4"
|
|
||||||
},
|
},
|
||||||
"@std/io@0.225.2": {
|
"@std/io@0.225.2": {
|
||||||
"integrity": "3c740cd4ee4c082e6cfc86458f47e2ab7cb353dc6234d5e9b1f91a2de5f4d6c7"
|
"integrity": "3c740cd4ee4c082e6cfc86458f47e2ab7cb353dc6234d5e9b1f91a2de5f4d6c7"
|
||||||
@@ -49,40 +32,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
"@discordeno/bot@21.0.0": {
|
|
||||||
"integrity": "sha512-x6EcVHBvWIhjY5/lcwgZzzCiqdpKFZqu2qUaZqKb7RYS8L8Q8zY40hCnbToVehLB8+BGcnHzxCeEvWWg8tnT/g==",
|
|
||||||
"dependencies": [
|
|
||||||
"@discordeno/gateway",
|
|
||||||
"@discordeno/rest",
|
|
||||||
"@discordeno/types",
|
|
||||||
"@discordeno/utils"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"@discordeno/gateway@21.0.0": {
|
|
||||||
"integrity": "sha512-ur5Hatd1x86PPI4UnXKghAWat3vS90NvLJcpOSu1B1gYSENRZow8dohZ8Ov58SXWq5nZVuBYDJNCR248pWJvrg==",
|
|
||||||
"dependencies": [
|
|
||||||
"@discordeno/types",
|
|
||||||
"@discordeno/utils",
|
|
||||||
"fzstd",
|
|
||||||
"ws"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"@discordeno/rest@21.0.0": {
|
|
||||||
"integrity": "sha512-ew5ddhUd7Qyv/GSzCy42bEmRv0yr2PspCMsLD/NeMiTLd3+OrVN5pAxBN9z+9JpS/daiiD/PVmvuUAVx/nXTEw==",
|
|
||||||
"dependencies": [
|
|
||||||
"@discordeno/types",
|
|
||||||
"@discordeno/utils"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"@discordeno/types@21.0.0": {
|
|
||||||
"integrity": "sha512-TUZAEqqlXRNQji+NCaQo8DruzI8rXbBvMaZYsZvN9f03PrdSddzMOy3cjs4eeL6ZMVocmMVRIaVnB713blylCw=="
|
|
||||||
},
|
|
||||||
"@discordeno/utils@21.0.0": {
|
|
||||||
"integrity": "sha512-I7I3Szlk+LkT/CRmJJiLPsjuBUjbuXUCvOzsgWCltkxDMIGmQeNoQtFK7t89V1Gcc4icsrnHVMho1BcaAITijg==",
|
|
||||||
"dependencies": [
|
|
||||||
"@discordeno/types"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"@discordjs/builders@1.10.1": {
|
"@discordjs/builders@1.10.1": {
|
||||||
"integrity": "sha512-OWo1fY4ztL1/M/DUyRPShB4d/EzVfuUvPTRRHRIt/YxBrUYSz0a+JicD5F5zHFoNs2oTuWavxCOVFV1UljHTng==",
|
"integrity": "sha512-OWo1fY4ztL1/M/DUyRPShB4d/EzVfuUvPTRRHRIt/YxBrUYSz0a+JicD5F5zHFoNs2oTuWavxCOVFV1UljHTng==",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
@@ -192,22 +141,9 @@
|
|||||||
"undici"
|
"undici"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"discordeno@21.0.0": {
|
|
||||||
"integrity": "sha512-NX1x5GtHbrNhpeahfHw+2A6/3bpec2obNjIZ/mkBUGWcpLWG/ZgJSIkkdQIxcrnQ3loQooo/5IpBucnFTiGATA==",
|
|
||||||
"dependencies": [
|
|
||||||
"@discordeno/bot",
|
|
||||||
"@discordeno/gateway",
|
|
||||||
"@discordeno/rest",
|
|
||||||
"@discordeno/types",
|
|
||||||
"@discordeno/utils"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"fast-deep-equal@3.1.3": {
|
"fast-deep-equal@3.1.3": {
|
||||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
|
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
|
||||||
},
|
},
|
||||||
"fzstd@0.1.1": {
|
|
||||||
"integrity": "sha512-dkuVSOKKwh3eas5VkJy1AW1vFpet8TA/fGmVA5krThl8YcOVE/8ZIoEA1+U1vEn5ckxxhLirSdY837azmbaNHA=="
|
|
||||||
},
|
|
||||||
"lodash.snakecase@4.1.1": {
|
"lodash.snakecase@4.1.1": {
|
||||||
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw=="
|
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw=="
|
||||||
},
|
},
|
||||||
|
|||||||
35
src/bot.ts
35
src/bot.ts
@@ -1,14 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
ChatInputCommandInteraction,
|
|
||||||
Client,
|
Client,
|
||||||
Events,
|
Events,
|
||||||
GatewayIntentBits,
|
GatewayIntentBits,
|
||||||
REST,
|
REST,
|
||||||
Routes,
|
Routes,
|
||||||
SlashCommandBuilder,
|
|
||||||
} from "@discordjs";
|
} from "@discordjs";
|
||||||
import * as stdDotenv from "jsr:@std/dotenv@0.225.3";
|
import * as stdDotenv from "jsr:@std/dotenv@0.225.3";
|
||||||
import { commandRouter } from "@root/commands.ts";
|
import { commandRouter } from "@root/commands.ts";
|
||||||
|
|
||||||
const env = await stdDotenv.load();
|
const env = await stdDotenv.load();
|
||||||
|
|
||||||
const token = env.TOKEN;
|
const token = env.TOKEN;
|
||||||
@@ -31,11 +30,15 @@ client.on(Events.ClientReady, (readyClient) => {
|
|||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const commands = commandRouter();
|
||||||
|
|
||||||
client.on(Events.InteractionCreate, async (interaction) => {
|
client.on(Events.InteractionCreate, async (interaction) => {
|
||||||
// messagehandler(interaction.command)
|
// messagehandler(interaction.command)
|
||||||
if (!interaction.isChatInputCommand()) return;
|
if (!interaction.isChatInputCommand()) return;
|
||||||
if (interaction.commandName === "gif") {
|
|
||||||
await commands.execute(interaction)
|
const command = commands.find((c) => c.data.name === interaction.commandName);
|
||||||
|
if (command) {
|
||||||
|
await command.execute(interaction);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -43,27 +46,6 @@ client.on(Events.Error, (e) => {
|
|||||||
reject(e);
|
reject(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
// const commands = commandRouter()
|
|
||||||
//test
|
|
||||||
const commands = {
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName('gif')
|
|
||||||
.setDescription('Sends a random gif!')
|
|
||||||
.addStringOption(option =>
|
|
||||||
option.setName('category')
|
|
||||||
.setDescription('The gif category')
|
|
||||||
.setRequired(true)
|
|
||||||
.addChoices(
|
|
||||||
{ name: 'Funny', value: 'gif_funny' },
|
|
||||||
{ name: 'Meme', value: 'gif_meme' },
|
|
||||||
{ name: 'Movie', value: 'gif_movie' },
|
|
||||||
)),
|
|
||||||
async execute(interaction: ChatInputCommandInteraction) {
|
|
||||||
const category = interaction.options.getString('category');
|
|
||||||
await interaction.reply(`You chose: ${category}`);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const rest = new REST({ version: "10" }).setToken(token);
|
const rest = new REST({ version: "10" }).setToken(token);
|
||||||
|
|
||||||
client.login(token);
|
client.login(token);
|
||||||
@@ -73,10 +55,11 @@ await promise;
|
|||||||
try {
|
try {
|
||||||
console.log("Started refreshing application (/) commands.");
|
console.log("Started refreshing application (/) commands.");
|
||||||
if (client.application === null) throw Error("client.application is null!!!");
|
if (client.application === null) throw Error("client.application is null!!!");
|
||||||
|
|
||||||
await rest.put(
|
await rest.put(
|
||||||
Routes.applicationCommands(client.application.id),
|
Routes.applicationCommands(client.application.id),
|
||||||
{
|
{
|
||||||
body: [commands.data.toJSON()],
|
body: commands.map(c => c.data.toJSON()),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,6 @@ import {commands as yandereCommands} from "./plugins/yandere/commands.ts";
|
|||||||
import {commands as ruleCommands} from "./plugins/rule34/commands.ts";
|
import {commands as ruleCommands} from "./plugins/rule34/commands.ts";
|
||||||
|
|
||||||
export function commandRouter() {
|
export function commandRouter() {
|
||||||
return [...yandereCommands, ...ruleCommands]
|
const combinedCommands = [...yandereCommands, ...ruleCommands];
|
||||||
|
return combinedCommands;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { ChatInputCommandInteraction, SlashCommandBuilder } from "@discordjs";
|
||||||
ChatInputCommandInteraction,
|
|
||||||
CommandInteractionOptionResolver,
|
|
||||||
InteractionCallback,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
} from "@discordjs";
|
|
||||||
// import { drop, help, requestWorker } from "./plugin.ts";
|
// import { drop, help, requestWorker } from "./plugin.ts";
|
||||||
import { logMessage } from "@root/logging.ts";
|
import { logMessage } from "@root/logging.ts";
|
||||||
import { defaultString } from "@root/defaultString.ts";
|
import { defaultString } from "@root/defaultString.ts";
|
||||||
@@ -38,30 +33,14 @@ export const commands = [
|
|||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("rule")
|
.setName("rule")
|
||||||
.setDescription("Drops one or multiple images using the rule34 API.")
|
.setDescription("Drops one or multiple images using the rule34 API.")
|
||||||
.setNSFW(true)
|
// .setNSFW(true)
|
||||||
.addSubcommand((subcommand) =>
|
.addSubcommand((subcommand) =>
|
||||||
subcommand
|
subcommand
|
||||||
.setName("drop")
|
.setName("drop")
|
||||||
.setDescription("Drops one or multiple images using the rule34 API.")
|
.setDescription("Drops one or multiple images using the rule34 API.")
|
||||||
),
|
),
|
||||||
|
async execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
await interaction.reply(`VIOLENCE!`);
|
||||||
},
|
},
|
||||||
{
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName("gif")
|
|
||||||
.setDescription("Sends a random gif!")
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option.setName("category")
|
|
||||||
.setDescription("The gif category")
|
|
||||||
.setRequired(true)
|
|
||||||
.addChoices(
|
|
||||||
{ name: "Funny", value: "gif_funny" },
|
|
||||||
{ name: "Meme", value: "gif_meme" },
|
|
||||||
{ name: "Movie", value: "gif_movie" },
|
|
||||||
)
|
|
||||||
),
|
|
||||||
async execute (interaction: ChatInputCommandInteraction) {
|
|
||||||
const category = interaction.options.getString('category');
|
|
||||||
await interaction.reply(`You chose: ${category}`);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { requestJSON } from "@root/structures/apiRequest.ts";
|
import { requestJSON } from "@root/structures/apiRequest.ts";
|
||||||
import { DiscordEmbed } from "npm:discordeno@21.0.0";
|
import { EmbedBuilder } from "@discordjs";
|
||||||
|
|
||||||
type PostResponse = {
|
type PostResponse = {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -74,26 +74,23 @@ function parsePostListArgs(url: URL, args: string) {
|
|||||||
|
|
||||||
async function returnDiscordEmbeds(
|
async function returnDiscordEmbeds(
|
||||||
url: URL,
|
url: URL,
|
||||||
): Promise<DiscordEmbed[]> {
|
) {
|
||||||
const response: PostResponse = await requestJSON<PostResponse>(
|
const response: PostResponse = await requestJSON<PostResponse>(
|
||||||
url.toString(),
|
url.toString(),
|
||||||
);
|
);
|
||||||
const embeds: DiscordEmbed[] = [];
|
const embeds = [];
|
||||||
for (const post of response) {
|
for (const post of response) {
|
||||||
embeds.push(
|
embeds.push(
|
||||||
|
new EmbedBuilder()
|
||||||
|
.setTitle(post.id.toString())
|
||||||
|
.setURL(post.file_url)
|
||||||
|
.setAuthor(
|
||||||
{
|
{
|
||||||
url: post.file_url,
|
|
||||||
title: post.id.toString(),
|
|
||||||
author: {
|
|
||||||
name: post.author,
|
name: post.author,
|
||||||
},
|
}
|
||||||
image: {
|
)
|
||||||
url: post.file_url,
|
.setImage(post.file_url)
|
||||||
width: post.width,
|
)
|
||||||
height: post.height,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return embeds;
|
return embeds;
|
||||||
}
|
}
|
||||||
@@ -107,7 +104,7 @@ async function returnDiscordEmbeds(
|
|||||||
* @param url URL Object
|
* @param url URL Object
|
||||||
* @param search Search string formatted like the following: [tags: something, page: 1, limit: 666], some parameters can miss.
|
* @param search Search string formatted like the following: [tags: something, page: 1, limit: 666], some parameters can miss.
|
||||||
*/
|
*/
|
||||||
export async function handlePostRequest(url: URL, search?: string): Promise<DiscordEmbed[]> {
|
export async function handlePostRequest(url: URL, search?: string) {
|
||||||
// const urlCopy = copyObject<URL>(url);
|
// const urlCopy = copyObject<URL>(url);
|
||||||
//parse
|
//parse
|
||||||
if (search) {
|
if (search) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { SlashCommandBuilder } from "@discordjs";
|
import {
|
||||||
import { logMessage } from "@root/logging.ts";
|
ChatInputCommandInteraction,
|
||||||
|
SlashCommandBuilder,
|
||||||
|
} from "@discordjs";
|
||||||
import { getPosts } from "@root/plugins/yandere/api/api.ts";
|
import { getPosts } from "@root/plugins/yandere/api/api.ts";
|
||||||
|
|
||||||
// export async function yandereMessageHandler(message: Message) {
|
// export async function yandereMessageHandler(message: Message) {
|
||||||
@@ -26,8 +28,31 @@ import { getPosts } from "@root/plugins/yandere/api/api.ts";
|
|||||||
export const commands = [
|
export const commands = [
|
||||||
{
|
{
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
.setName("yande")
|
||||||
|
.setDescription("Drops one or multiple images using the yande.re API.")
|
||||||
|
// .setNSFW(true),
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
.setName("drop")
|
.setName("drop")
|
||||||
.setDescription("Drops one or multiple images using the yande.re API.")
|
.setDescription("Drops one or multiple images using the yande.re API.")
|
||||||
.setNSFW(true),
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName("limit")
|
||||||
|
.setDescription("Post limitation")
|
||||||
|
)
|
||||||
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName("tags")
|
||||||
|
.setDescription("Tags to add to query")
|
||||||
|
)
|
||||||
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName("page")
|
||||||
|
.setDescription("Which page to query")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
async execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
await interaction.reply({embeds: await getPosts("[limit: 5]")});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user