zucar-framework

Advanced Framework for Discord.JS V13

Usage no npm install needed!

<script type="module">
  import zucarFramework from 'https://cdn.skypack.dev/zucar-framework';
</script>

README

Image Image

Image">

News

- Fixed Readme

Warn

- Node.JS version must be 16 or higher.
- Discord.JS version should be 13.

Import

const { ZucarClient, ZucarHandler } = require("zucar-framework");

Client

/**
 * @param {{ prefixs: string[]; owners: string[]; allIntents?: boolean }} ZucarOptions
 * @param {ClientOptions} [ClientOptions]
 */

const client = new ZucarClient(ZucarOptions, ClientOptions);

client.login("BOT TOKEN");

Handler

/**
 * @param {ZucarClient} client
 */

const Handler = new ZucarHandler(client);

//#SLASH COMMANDS

/**
 * @param {{ directory?: string }} [options]
 */

Handler.slashCommandHandler(options).then((commandNames) => {
    commandNames.forEach((commandName) => {
        console.log(`Slash command loaded: ${commandName}`);
    });
});

//#COMMANDS

/**
 * @param {{ directory?: string; modernArgs?: boolean; answerTheBots?: boolean }} [options]
 */

Handler.commandHandler(options).then((commandNames) => {
    commandNames.forEach((commandName) => {
        console.log(`Command loaded: ${commandName}`);
    });
});

//#EVENTS

/**
 * @param {ZucarClient} client
 */

Handler.eventHandler(options).then((eventNames) => {
    eventNames.forEach((eventName) => {
        console.log(`Event loaded: ${eventName}`);
    });
});

Slash Command Structure

/**
 * @param {ApplicationCommandOptionData[]} options
 */

module.exports = {
    name: "Command Name",
    description: "Command description for slash commands.",
    options: [], //Options for slash commands.
    ownerOnly: false, //Is the command for the bot owner?
    userPermissions: [], //User permissions.
    botPermissions: [], //Client permissions.
    execute: async (client, interaction) => {
        interaction.reply({ content: "Hi!", ephemeral: true });
    }
};

Normal Command Structure

module.exports = {
    name: "Command Name",
    ownerOnly: false, //Is the command for the bot owner?
    userPermissions: [], //User permissions.
    botPermissions: [], //Client permissions.
    cooldown: "3s", //Command cooldown.
    execute: async (client, message, args) => {
        message.reply({ content: "Hi!" });
    }
};

Modern Args Command Structure

/**
 * @param {{ id: string, type: "string" | "number" | "role" | "channel" | "user" }[]} args
 */

module.exports = {
    name: "Command Name",
    args: [], //args
    ownerOnly: false, //Is the command for the bot owner?
    userPermissions: [], //User permissions.
    botPermissions: [], //Client permissions.
    cooldown: "3s", //Command cooldown.
    execute: async (client, message, args) => {
        //Get string
        args.getString("id");

        //Get number
        args.getNumber("id");

        //Get user
        args.getUser("id");

        //Get Role
        args.getRole("id");

        //Get Channel
        args.getChannel("id");

        //Filter
        args.filter((element) => element.id === "id");

        //Find
        args.find((element) => element.id === "id");

        //Get Full Args
        args.getFullArgs; //Returns all args used.
    }
};

Event Structure

module.exports = {
    name: "Event Name",
    execute: async (client, ...args) => {
        console.log(client.user.username);
    }
};

Events

//#COMMAND HANDLER

Handler.on("commandUserPermissions", (message, permissionsArray) => {
    let permissions = permissionsArray.join(", ");
    message.reply({
        content: `You must have the following privileges for this command:\n\n${permissions}`
    });
});

Handler.on("commandClientPermissions", (message, permissionsArray) => {
    let permissions = permissionsArray.join(", ");
    message.reply({
        content: `I must have the following privileges for this command:\n\n${permissions}`
    });
});

Handler.on("commandOwnerOnly", (message) => {
    message.reply({
        content: `You are not my owner.`
    });
});

Handler.on("commandCooldown", (message, remainingTime) => {
    message.reply({
        content: `You must wait for ${remainingTime} to use this command again.`
    });
});

Handler.on("commandUsed", (message, commandName) => {
    console.log(`${message.author.tag} Command used, command name: ${commandName}`);
});

Handler.on("commandError", (message, commandName, error) => {
    message.reply({
        content: `An error occured.`
    });
    console.log(`Command ${commandName} gave the following error:\n\n${error}`);
});

Handler.on("commandNotFound", (message, commandName) => {
    message.reply({
        content: `This command ${commandName} was not found.`
    });
});

//#SLASH COMMAND HANDLER

Handler.on("slashCommandUserPermissions", (interaction, permissionsArray) => {
    let permissions = permissionsArray.join(", ");
    interaction.reply({
        content: `You must have the following privileges for this command:\n\n${permissions}`,
        ephemeral: true
    });
});

Handler.on("slashCommandClientPermissions", (interaction, permissionsArray) => {
    let permissions = permissionsArray.join(", ");
    interaction.reply({
        content: `I must have the following privileges for this command:\n\n${permissions}`,
        ephemeral: true
    });
});

Handler.on("slashCommandOwnerOnly", (interaction) => {
    interaction.reply({
        content: `You are not my owner.`,
        ephemeral: true
    });
});

Handler.on("slashCommandCooldown", (interaction, remainingTime) => {
    interaction.reply({
        content: `You must wait for ${remainingTime} to use this command again.`,
        ephemeral: true
    });
});

Handler.on("slashCommandUsed", (interaction, commandName) => {
    console.log(
        `${interaction.member.user.tag} Slash command used, slash command name: ${commandName}`
    );
});

Handler.on("slashCommandError", (interaction, commandName, error) => {
    interaction.reply({
        content: `An error occured.`,
        ephemeral: true
    });
    console.log(`Slash command ${commandName} gave the following error:\n\n${error}`);
});

Handler.on("slashCommandsSetted", () => {
    console.log("Slash commands ready!");
});

Handler.on("slashCommandsNotSetted", (error) => {
    console.log(`Slash commands not ready, error:\n\n${error}`);
});

Handler.on("slashCommandNotFound", (interaction, commandName) => {
    interaction.reply({
        content: `This command ${commandName} was not found.`,
        ephemeral: true
    });
});

//#EVENT HANDLER
Handler.on("eventError", (eventName, error) => {
    console.log(`Event ${eventName} gave the following error:\n\n${error}`);
});

Come to our discord server for support.

https://discord.gg/7XmYnqkhwx