yebe
v1.5.0
Published
Reusable utilities for Discord bot development in TypeScript.
Maintainers
Readme
Yebe
Yebe provides a collection of well-typed, practical utility functions designed to streamline common tasks and complex interactions when building bots with Discord.js. Focus on your bot's unique features, let Yebe handle the boilerplate.
Installation
# Using npm
npm install yebe discord.js
# Using yarn
yarn add yebe discord.jsNote:
discord.jsis a peer dependency and must be installed alongsideyebe.
Getting Started
Here's a quick example:
import { Client, GatewayIntentBits } from 'discord.js';
import { isSafeChannel, awaitUserInput } from 'yebe';
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
client.on('messageCreate', async (message) => {
const { channel, author } = message;
if (message.content === '!poll' && isSafeChannel(channel)) {
await channel.send('What’s your favorite color?');
const reply = await awaitUserInput(channel, author);
if (reply) {
await channel.send(`You said: ${reply.content}`);
} else {
await channel.send('No answer received.');
}
}
});
client.login('your-bot-token');
This example demonstrates isSafeChannel (a type-safe channel guard) and awaitUserInput, which collects a message reply from a user.
Documentation
For detailed information on all available functions, their parameters, return types, and usage examples, please refer to the Full API Documentation (generated by TypeDoc).
Contributing
Contributions are welcome! Please feel free to open an issue or submit a pull request if you have suggestions or improvements.
License
This project is licensed under the MIT License - see the LICENSE file for details.
