added async execute test
This commit is contained in:
25
src/bot.ts
25
src/bot.ts
@@ -1,9 +1,11 @@
|
|||||||
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";
|
||||||
@@ -45,7 +47,26 @@ client.on(Events.Error, (e) => {
|
|||||||
reject(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);
|
const rest = new REST({ version: "10" }).setToken(token);
|
||||||
|
|
||||||
@@ -59,7 +80,7 @@ try {
|
|||||||
await rest.put(
|
await rest.put(
|
||||||
Routes.applicationCommands(client.application.id),
|
Routes.applicationCommands(client.application.id),
|
||||||
{
|
{
|
||||||
body: commands,
|
body: [commands],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { SlashCommandBuilder } from "@discordjs";
|
import {
|
||||||
|
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";
|
||||||
@@ -19,7 +24,7 @@ import { defaultString } from "@root/defaultString.ts";
|
|||||||
// }
|
// }
|
||||||
// } else if (command === "help") {
|
// } else if (command === "help") {
|
||||||
// logMessage(message);
|
// logMessage(message);
|
||||||
|
|
||||||
// bot.helpers.sendMessage(message.channelId, {
|
// bot.helpers.sendMessage(message.channelId, {
|
||||||
// content: defaultString(help()),
|
// content: defaultString(help()),
|
||||||
// });
|
// });
|
||||||
@@ -29,26 +34,34 @@ import { defaultString } from "@root/defaultString.ts";
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
export const commands = [
|
export const commands = [
|
||||||
new SlashCommandBuilder()
|
{
|
||||||
.setName("rule")
|
data: new SlashCommandBuilder()
|
||||||
.setDescription("Drops one or multiple images using the rule34 API.")
|
.setName("rule")
|
||||||
.setNSFW(true)
|
.setDescription("Drops one or multiple images using the rule34 API.")
|
||||||
.addSubcommand(subcommand =>
|
.setNSFW(true)
|
||||||
subcommand
|
.addSubcommand((subcommand) =>
|
||||||
.setName("drop")
|
subcommand
|
||||||
.setDescription("Drops one or multiple images using the rule34 API.")
|
.setName("drop")
|
||||||
|
.setDescription("Drops one or multiple images using the rule34 API.")
|
||||||
),
|
),
|
||||||
new SlashCommandBuilder()
|
},
|
||||||
.setName('gif')
|
{
|
||||||
.setDescription('Sends a random gif!')
|
data: new SlashCommandBuilder()
|
||||||
.addStringOption(option =>
|
.setName("gif")
|
||||||
option.setName('category')
|
.setDescription("Sends a random gif!")
|
||||||
.setDescription('The gif category')
|
.addStringOption((option) =>
|
||||||
.setRequired(true)
|
option.setName("category")
|
||||||
.addChoices(
|
.setDescription("The gif category")
|
||||||
{ name: 'Funny', value: 'gif_funny' },
|
.setRequired(true)
|
||||||
{ name: 'Meme', value: 'gif_meme' },
|
.addChoices(
|
||||||
{ 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}`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { SlashCommandBuilder} from "@discordjs";
|
import { SlashCommandBuilder } from "@discordjs";
|
||||||
import { logMessage } from "@root/logging.ts";
|
import { logMessage } from "@root/logging.ts";
|
||||||
import { getPosts } from "@root/plugins/yandere/api/api.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 = [
|
export const commands = [
|
||||||
new SlashCommandBuilder()
|
{
|
||||||
.setName("drop")
|
data: new SlashCommandBuilder()
|
||||||
.setDescription("Drops one or multiple images using the yande.re API.")
|
.setName("drop")
|
||||||
.setNSFW(true)
|
.setDescription("Drops one or multiple images using the yande.re API.")
|
||||||
]
|
.setNSFW(true),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user