Skip to content
/ meinu Public

Simplifies the creation and handling of slash commands in Discord bots.

License

Notifications You must be signed in to change notification settings

itss0n1c/meinu

Repository files navigation

Meinu

Discord server npm version npm downloads

Simplifies the creation and handling of slash commands in Discord bots.

Installation

% bun i meinu

Basic Usage

import { Meinu, Command } from 'meinu';

let commands = [
	new Command<Meinu>({
		name: 'ping',
		description: 'Pong!',
		owners_only: true, // default: false
		nsfw: true, // default: false
	}).addHandler('chat_input', async (bot, int) => {
		const sent = await int.deferReply({ withResponse: true });
		if (!sent.resource?.message?.createdTimestamp)
			return int.editReply('An error occured while executing the command.');
		const diff = sent.resource?.message?.createdTimestamp - int.createdTimestamp;

		const content = [
			'### 🏓 Pong!',
			`## ${diff}ms`,
			...(bot.isSharding ? [`-# via shard #${bot.shardId}`] : []),
		].join('\n');

		return int.editReply(content);
	})
];

new Meinu({
	name: 'MyBot',
	color: 'LuminousVividPink',
})
	.register_commands(commands)
	.init(); // starts the bot, .init(TOKEN) if `TOKEN` env is not set

Scrollable

Meinu includes a class called Scrollable which can be used to create scrollable content.

To initate this class, you can use the create_scrollable function.

import { Command, create_scrollable } from 'meinu';

new Command({})
.addHandler("chat_input", (bot, int) => create_scrollable({
	int,
	data: () => [{ title: "foo" }, { title: "bar" }],
	match: (v) => ({
    	content: `## ${v.title}`
  	})
}));