added async execute test

This commit is contained in:
fzzinchemical
2025-04-15 06:40:39 +02:00
parent 1f3090d799
commit 0473e32b39
3 changed files with 69 additions and 33 deletions

View File

@@ -1,9 +1,11 @@
import {
ChatInputCommandInteraction,
Client,
Events,
GatewayIntentBits,
REST,
Routes,
SlashCommandBuilder,
} from "@discordjs";
import * as stdDotenv from "jsr:@std/dotenv@0.225.3";
import { commandRouter } from "@root/commands.ts";
@@ -45,7 +47,26 @@ client.on(Events.Error, (e) => {
reject(e);
});
const commands = commandRouter()
// 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);
@@ -59,7 +80,7 @@ try {
await rest.put(
Routes.applicationCommands(client.application.id),
{
body: commands,
body: [commands],
},
);

View File

@@ -1,4 +1,9 @@
import { SlashCommandBuilder } from "@discordjs";
import {
ChatInputCommandInteraction,
CommandInteractionOptionResolver,
InteractionCallback,
SlashCommandBuilder,
} from "@discordjs";
// import { drop, help, requestWorker } from "./plugin.ts";
import { logMessage } from "@root/logging.ts";
import { defaultString } from "@root/defaultString.ts";
@@ -29,26 +34,34 @@ import { defaultString } from "@root/defaultString.ts";
// }
export const commands = [
new SlashCommandBuilder()
{
data: new SlashCommandBuilder()
.setName("rule")
.setDescription("Drops one or multiple images using the rule34 API.")
.setNSFW(true)
.addSubcommand(subcommand =>
.addSubcommand((subcommand) =>
subcommand
.setName("drop")
.setDescription("Drops one or multiple images using the rule34 API.")
),
new SlashCommandBuilder()
.setName('gif')
.setDescription('Sends a random gif!')
.addStringOption(option =>
option.setName('category')
.setDescription('The gif category')
},
{
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' },
))
]
{ 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}`);
}
},
];

View File

@@ -1,4 +1,4 @@
import { SlashCommandBuilder} from "@discordjs";
import { SlashCommandBuilder } from "@discordjs";
import { logMessage } from "@root/logging.ts";
import { getPosts } from "@root/plugins/yandere/api/api.ts";
@@ -24,8 +24,10 @@ import { getPosts } from "@root/plugins/yandere/api/api.ts";
// }
export const commands = [
new SlashCommandBuilder()
{
data: new SlashCommandBuilder()
.setName("drop")
.setDescription("Drops one or multiple images using the yande.re API.")
.setNSFW(true)
]
.setNSFW(true),
},
];