Eliminated Discordeno, functional and runnable.

This commit is contained in:
fzzinchemical
2025-04-15 15:49:35 +02:00
parent 63db6fb27a
commit 1e0a01d771
7 changed files with 63 additions and 142 deletions

View File

@@ -1,9 +1,4 @@
import {
ChatInputCommandInteraction,
CommandInteractionOptionResolver,
InteractionCallback,
SlashCommandBuilder,
} from "@discordjs";
import { ChatInputCommandInteraction, SlashCommandBuilder } from "@discordjs";
// import { drop, help, requestWorker } from "./plugin.ts";
import { logMessage } from "@root/logging.ts";
import { defaultString } from "@root/defaultString.ts";
@@ -38,30 +33,14 @@ export const commands = [
data: new SlashCommandBuilder()
.setName("rule")
.setDescription("Drops one or multiple images using the rule34 API.")
.setNSFW(true)
// .setNSFW(true)
.addSubcommand((subcommand) =>
subcommand
.setName("drop")
.setDescription("Drops one or multiple images using the rule34 API.")
),
},
{
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}`);
}
async execute(interaction: ChatInputCommandInteraction) {
await interaction.reply(`VIOLENCE!`);
},
},
];

View File

@@ -1,5 +1,5 @@
import { requestJSON } from "@root/structures/apiRequest.ts";
import { DiscordEmbed } from "npm:discordeno@21.0.0";
import { EmbedBuilder } from "@discordjs";
type PostResponse = {
id: number;
@@ -74,26 +74,23 @@ function parsePostListArgs(url: URL, args: string) {
async function returnDiscordEmbeds(
url: URL,
): Promise<DiscordEmbed[]> {
) {
const response: PostResponse = await requestJSON<PostResponse>(
url.toString(),
);
const embeds: DiscordEmbed[] = [];
const embeds = [];
for (const post of response) {
embeds.push(
{
url: post.file_url,
title: post.id.toString(),
author: {
name: post.author,
},
image: {
url: post.file_url,
width: post.width,
height: post.height,
},
},
);
new EmbedBuilder()
.setTitle(post.id.toString())
.setURL(post.file_url)
.setAuthor(
{
name: post.author,
}
)
.setImage(post.file_url)
)
}
return embeds;
}
@@ -107,7 +104,7 @@ async function returnDiscordEmbeds(
* @param url URL Object
* @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);
//parse
if (search) {

View File

@@ -1,5 +1,7 @@
import { SlashCommandBuilder } from "@discordjs";
import { logMessage } from "@root/logging.ts";
import {
ChatInputCommandInteraction,
SlashCommandBuilder,
} from "@discordjs";
import { getPosts } from "@root/plugins/yandere/api/api.ts";
// export async function yandereMessageHandler(message: Message) {
@@ -26,8 +28,31 @@ import { getPosts } from "@root/plugins/yandere/api/api.ts";
export const commands = [
{
data: new SlashCommandBuilder()
.setName("drop")
.setName("yande")
.setDescription("Drops one or multiple images using the yande.re API.")
.setNSFW(true),
// .setNSFW(true),
.addSubcommand((subcommand) =>
subcommand
.setName("drop")
.setDescription("Drops one or multiple images using the yande.re API.")
.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]")});
},
},
];