A powerful and extendable Discord bot, with it's own module system :3
thevoid.cafe/projects/voidy
1import { Command, devOnly } from "@voidy/framework";
2import { MessageFlags, SlashCommandBuilder } from "discord.js";
3
4export default new Command({
5 id: "exec",
6 use: [devOnly],
7 data: new SlashCommandBuilder()
8 .setName("exec")
9 .setDescription("Evaluates the user-supplied JavaScript code, has access to standard command context information.")
10 .addStringOption((option) =>
11 option.setName("code").setDescription("The code to evaluate.").setRequired(true),
12 ),
13
14 execute: async (ctx) => {
15 const { interaction } = ctx;
16 const code = interaction.options.getString("code", true);
17
18 try {
19 const fn = new Function("ctx", "interaction", "client", code);
20 const result = await fn(ctx, interaction, ctx.client);
21 const output = typeof result === "string" ? result : Bun.inspect(result, { depth: 2 });
22
23 await interaction.reply({
24 content: `\`\`\`\n${output.slice(0, 1900)}\n\`\`\``,
25 flags: [MessageFlags.Ephemeral],
26 });
27 } catch (err) {
28 await interaction.reply({
29 content: `\`\`\`\n${err}\n\`\`\``,
30 flags: [MessageFlags.Ephemeral],
31 });
32 }
33 }
34});