A powerful and extendable Discord bot, with it's own module system :3
thevoid.cafe/projects/voidy
1import { MessageFlags, PermissionFlagsBits, SlashCommandSubcommandBuilder } from "discord.js";
2import { Command, requirePermission } from "@voidy/framework";
3import { ChatbotRepository } from "../../schemas/ChatbotRepository";
4
5export default new Command({
6 id: "chatbot.repository.create",
7 use: [requirePermission(PermissionFlagsBits.ManageGuild)],
8 data: new SlashCommandSubcommandBuilder()
9 .setName("create")
10 .setDescription("Create a new local content repository.")
11 .addStringOption((option) =>
12 option.setName("name").setDescription("Repository name.").setRequired(true),
13 ),
14
15 execute: async ({ interaction }) => {
16 const name = interaction.options.getString("name", true);
17
18 const existing = await ChatbotRepository.findOne({
19 scope: "local",
20 guildId: interaction.guildId,
21 name,
22 });
23
24 if (existing) {
25 await interaction.reply({
26 content: `A local repository named "${name}" already exists.`,
27 flags: [MessageFlags.Ephemeral],
28 });
29 return;
30 }
31
32 await ChatbotRepository.create({
33 name,
34 scope: "local",
35 guildId: interaction.guildId,
36 });
37
38 await interaction.reply({
39 content: `Local repository "${name}" created. Add messages and profiles with \`/chatbot message add\` and \`/chatbot profile add\`.`,
40 flags: [MessageFlags.Ephemeral],
41 });
42 },
43});