Global Helpers

Global functions and shortcuts available everywhere in your bot.

🔘 Button Helpers

button()

Create a button component:

// Simple button
const btn = button('confirm', 'Confirm', 'Primary');
// With styles
button('delete', 'Delete', 'Danger');
button('cancel', 'Cancel', 'Secondary');
button('success', 'Done', 'Success');
// Usage in reply
await this.reply({
content: 'Choose an option:',
components: [
row(
button('yes', 'Yes', 'Success'),
button('no', 'No', 'Danger')
)
]
});

Available Styles

  • Primary - Blurple (default)
  • Secondary - Gray
  • Success - Green
  • Danger - Red
  • Link - Link button

row()

Create action row for buttons:

// Single row
const actionRow = row(
button('btn1', 'Button 1'),
button('btn2', 'Button 2'),
button('btn3', 'Button 3')
);
// Multiple rows (up to 5)
await this.reply({
content: 'Multiple rows:',
components: [
row(button('a', 'A'), button('b', 'B')),
row(button('c', 'C'), button('d', 'D')),
row(button('e', 'E'), button('f', 'F'))
]
});

onButton()

Handle button clicks:

commands/example.js
// Register button handler
onButton('confirm', async function() {
await this.update('Confirmed! ✅');
});
onButton('delete', async function() {
await this.update({
content: 'Deleted!',
components: [] // Remove buttons
});
});
// Access button interaction
onButton('info', async function(interaction) {
await this.reply(`Clicked by ${interaction.user.username}`);
});

📋 Embed Helper

embed()

Quick embed creation with auto string conversion:

// Simple embed
const myEmbed = embed({
title: 'Hello',
description: 'World',
color: 0x00d9ff
});
await this.reply({ embeds: [myEmbed] });
// With all options
const richEmbed = embed({
title: 'User Profile',
description: 'User information',
color: 0x00ff00,
thumbnail: user.displayAvatarURL(),
image: 'https://example.com/banner.png',
footer: 'Bot v1.0',
timestamp: true,
fields: [
{ name: 'ID', value: user.id },
{ name: 'Joined', value: user.createdAt, inline: true }
]
});
// Auto string conversion for fields
const statsEmbed = embed({
title: 'Stats',
fields: [
{ name: 'Count', value: 123 }, // Auto converts to "123"
{ name: 'Active', value: true } // Auto converts to "true"
]
});

📝 Logging Functions

Auto-logging to Discord channels (requires log channel setup).

log()

// Simple log
await log('User joined the server');
// With options
await log('Important event', {
guild: someGuild,
channel: 'logs'
});

Specialized Logs

// Info log (blue)
await logInfo('Bot started', 'System');
// Warning log (yellow)
await logWarning('High memory usage detected');
// Error log (red)
await logError(error, 'Command execution failed');
// Success log (green)
await logSuccess('Database backup completed');

📡 Event Listeners

on()

Listen to Discord events:

utils/events.js
// Member join
on('guildMemberAdd', async (member) => {
const channel = member.guild.channels.cache.find(
ch => ch.name === 'welcome'
);
if (channel) {
await channel.send(`Welcome ${member}! 👋`);
}
});
// Message create
on('messageCreate', async (message) => {
if (message.content === '!ping') {
await message.reply('Pong!');
}
});
// Reaction add
on('messageReactionAdd', async (reaction, user) => {
console.log(`${user.username} reacted with ${reaction.emoji.name}`);
});

once()

Listen to event only once:

// Bot ready (runs once)
once('ready', () => {
console.log('Bot is ready!');
});
// First message
once('messageCreate', (message) => {
console.log('First message received!');
});

📺 Channel Helpers

createChannel()

// Simple text channel
const channel = await createChannel('general');
// With options
const voiceChannel = await createChannel('Voice Chat', {
type: 2, // Voice channel
topic: 'Voice chat for gaming',
category: categoryId,
reason: 'Created for community'
});

findChannel()

// Find by name
const logsChannel = findChannel('logs');
if (logsChannel) {
await logsChannel.send('Found the channel!');
}

sendTo()

// Send to channel by name
await sendTo('announcements', 'Hello everyone!');
// Send to channel by ID
await sendTo('123456789', {
embeds: [embed({ title: 'Announcement' })]
});

🌍 Global Data Access

These properties are available in command context:

user

Current user who ran the command

guild

Current server/guild

channel

Current channel

random

Random utility functions

emoji

Custom emoji dictionary

vals

Global values from vals/ folder

📚 Complete Example

commands/menu.js
// Define command with buttons
bot.command.new('menu', 'Show menu', async function() {
await this.reply({
embeds: [embed({
title: 'Main Menu',
description: 'Choose an option below',
color: this.vals.colors.primary
})],
components: [
row(
button('profile', '👤 Profile', 'Primary'),
button('settings', '⚙️ Settings', 'Secondary')
),
row(
button('help', '❓ Help', 'Success'),
button('exit', '❌ Exit', 'Danger')
)
]
});
});
// Handle button clicks
onButton('profile', async function() {
await this.update({
embeds: [embed({
title: `${this.user.username}'s Profile`,
thumbnail: this.user.displayAvatarURL(),
fields: [
{ name: 'ID', value: this.user.id },
{ name: 'Joined', value: this.user.createdAt.toDateString() }
],
color: 0x00d9ff
})],
components: []
});
await logInfo(`${this.user.username} viewed their profile`);
});
onButton('settings', async function() {
await this.update({
content: '⚙️ Settings panel (coming soon)',
embeds: [],
components: [
row(button('back', '« Back', 'Secondary'))
]
});
});
onButton('help', async function() {
await sendTo('support', `${this.user} requested help`);
await this.update('✅ Help request sent!');
});
onButton('exit', async function() {
await this.update({
content: '👋 Goodbye!',
components: []
});
});
onButton('back', async function() {
// Re-show menu
await this.update({
embeds: [embed({
title: 'Main Menu',
description: 'Choose an option below',
color: 0x00d9ff
})],
components: [
row(
button('profile', '👤 Profile', 'Primary'),
button('settings', '⚙️ Settings', 'Secondary')
)
]
});
});

📖 Quick Reference

Buttons

button(id, label, style)
row(...components)
onButton(id, handler)

Embeds

embed(options)

Logging

log(message, options)
logInfo(message, title)
logWarning(message)
logError(error, context)
logSuccess(message)

Events

on(event, handler)
once(event, handler)

Channels

createChannel(name, opts)
findChannel(name)
sendTo(channel, content)