fast-discord-js
Version:
FastDiscordJS is an unofficial extension of the 'discord.js' library. Our extension aims to simplify the development of Discord bots, promoting cleaner code and easier maintenance.
20 lines (13 loc) • 714 B
text/typescript
import { ActionRowBuilder, AnyComponentBuilder } from 'discord.js';
function CreateRow(...components: any[]): ActionRowBuilder<any> {
if (components.length === 0 || (Array.isArray(components[0]) && components[0].length === 0)) {
throw new Error('>> ActionRowComponent requires at least one component');
}
// Flatten the array if the first element is an array
if (Array.isArray(components[0])) components = components[0];
if (components.length > 5) throw new Error('>> ActionRowComponent can only have up to 5 components');
const row = new ActionRowBuilder<any>();
row.addComponents(...(components as any[]));
return row;
}
export default CreateRow;