Repository navigation
Quick Start
İbrahim edited this page Dec 15, 2025
·
4 revisions
npm install mini-interaction dotenv
dotenvis recommended to keep your secrets.
Add command modules under src/commands. Each file should export a command definition with a data payload (the slash-command JSON) and a handler that either returns a Discord-compatible response or uses the helper methods on the provided interaction to send one.
// src/commands/ping.ts
import {
CommandBuilder,
CommandContext,
IntegrationType,
MiniInteractionCommand,
CommandInteraction,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
MiniComponentMessageActionRow,
} from "mini-interaction";
const ping: MiniInteractionCommand = {
data: new CommandBuilder()
.setName("ping")
.setDescription("Replies with pong!")
.setContexts([CommandContext.Guild])
.setIntegrationTypes([IntegrationType.GuildInstall])
.toJSON(),
handler: async (interaction: CommandInteraction) => {
const button = new ActionRowBuilder<MiniComponentMessageActionRow>()
.addComponents(
new ButtonBuilder()
.setCustomId("ping:announce")
.setLabel("Ping")
.setStyle(ButtonStyle.Primary),
)
.toJSON();
interaction.reply({ content: "Ping", components: [button] });
},
};
export default ping;Add command modules under src/components. Each file should export a customId and a handler that response to component interactions.
// src/components/pingButton.ts
import {
InteractionReplyFlags,
type MiniInteractionComponent,
} from "mini-interaction";
const pingButton: MiniInteractionComponent = {
customId: "ping:announce",
handler: (interaction) => {
const username = interaction.member?.user.username;
interaction.reply({
content: `Hi ${username}. How are you?`,
flags: InteractionReplyFlags.Ephemeral,
});
},
};
export default pingButton;