Skip to content

Releases: yetnt/ic4d

v5.0.0-beta.0

02 Mar 11:32

Choose a tag to compare

v5.0.0-beta.0 Pre-release
Pre-release

Removed all that client bs

Full Changelog: v4.0.1...v5.0.0-beta.0

v4.0.1

03 Dec 14:10

Choose a tag to compare

i didnt run npx tsc.
Full Changelog: v4.0.0...v4.0.1

v4.0.0

03 Dec 13:22

Choose a tag to compare

Github Wiki do not as of yet reflect the current docs of v4.0.0 but are still on v3.0.0
README.md will always have the updated docs however.

Breaking changes

All Handlers NO LONGER extend from Corehandler, and now instead their first parameters do not take a Client instance but a CoreHandler instance.

- const { CommandHandler, ReadyHandler, InteractionHandler } = require("ic4d")
+ const { CommandHandler, ReadyHandler, InteractionHandler, CoreHandler } = require("ic4d")

const client = new Client()

+ const core = new CoreHandler(client)

- const cHandler = new CommandHandler(client, "commands", ...etc )
+ const cHandler = new CommandHandler(core, "commands", ...etc )

And so on and so fourth.

ReadyHandler's second parameter now takes in a parameter called shardClient. If you are NOT sharding, leave as undefined then continue adding params.

const { ReadyHandler, CoreHandler } = require("ic4d")

const client = new Client()

const core = new CoreHandler(client)

- const rHandler(client, () => {}, () => {})
+ const rHandler(core, undefined, () => {}, () => {})

CommandHandler's handleCommands() method takes in 2 parameters instead of 1 rest parameter. Both parameters are arrays of functions

- cHandler.handleCommands(func1, func2, ...etc)
+ cHandler.handleCommands([func1, func2, ...etc]) 

New Stuff

Shared variables between Commands and interactions.

Via the addInteractionVariables() function passed into the execute() function of the SlashCommandManager's constructor object, and variables property passed into the fn() function of the setCallback() method in InteractionBuilder, variables can be passed as key-value pairs!

if that didn't make any sense, here is the docs on it

and here are the types:

type addInteractionVariables = (k: { [key: string]: any }) => void;
type variables = { [key:string]: any } 

and then here's an exmaple code of how you can use it

const test = new SlashCommandManager({
    data: new SlashCommandBuilder()
        .setName("test")
        .setDescription("Just a test")
        .addStringOption((option) =>
            option
                .setName("string")
                .setDescription("some input")
                .setRequired(true)
        ),
    // here we add the function in the parameter list
    async execute(interaction, client, addInteractionVariables) {
        try {
            await interaction.deferReply();
            const itemName = interaction.options.get("string").value;
            await interaction.editReply({
                content: "Huh?",
                components: [
                    new ActionRowBuilder().addComponents(
                        new ButtonBuilder()
                            .setCustomId("hello")
                            .setLabel("click now")
                            .setStyle(ButtonStyle.Primary)
                    ),
                ],
            });

            // using the function
            addInteractionVariables({ itemName });
        } catch (e) {
            errorHandler(e, client, interaction, EmbedBuilder);
        }
    },
}).addInteractions(button);

const button = new InteractionBuilder()
    .setType("button")
    .setCustomId("hello")

    // add the variables to the parameter list
    .setCallback(async (i, c, variables) => {
        // using the variable in the callback
        await i.update({ content: variables.itemName, components: [] });
    });

handleCommands() (from CommandHandler) now takes in a second parameter called postWare which is an array of functions run AFTER a command is run

Unlike middleWare which returns 1, or 0. postWare it doesn't matter what it returns.
Example : (Stolen from the docs)

const handler = new CommandHandler(core, path.join(__dirname, "commands"));

const blacklisted = ["302983482377931"];
const blacklist = (commandObject, interaction) => {
    if (commandObject.blacklist && blacklisted.includes(interaction.user.id)) {
        interaction.reply({
            content: "Daang you blacklisted my guy.",
            ephemeral: true,
        });
        return 1;
    }
    return 0;
};

const addXp = (commandObject, interaction) => {
    if (commandObject.category != "economy") return;
    interaction.reply({
        content: "Ayo! Free Xp +2",
        ephemeral: true,
    });
};

await handler.handleCommands([blacklist], [addXp]);

Sharding!

Well, not quite yet. Although nobody but me uses this package so unless i get a PR or actually start sharding my main bot. I'll update the docs better on this. Right now it should look okay but it's a bit funky.

Docs for sharding

Merged PRs

  • Merge variable scoping into main by @yetnt in #1
  • CoreHandler is no longer a parent class to all the other Handlers by @yetnt in #2

Full Changelog: v3.0.0...v4.0.0

v4.0.0-beta.6

01 Dec 14:37

Choose a tag to compare

v4.0.0-beta.6 Pre-release
Pre-release

fix mistake

Full Changelog: v4.0.0-beta.5...v4.0.0-beta.6

v4.0.0-beta.5

01 Dec 12:06

Choose a tag to compare

v4.0.0-beta.5 Pre-release
Pre-release

What's Changed

  • CoreHandler is no longer a parent class to all the other Handlers by @yetnt in #2

Full Changelog: v4.0.0-beta.4...v4.0.0-beta.5

v4.0.0-beta.4

17 Nov 11:52

Choose a tag to compare

v4.0.0-beta.4 Pre-release
Pre-release

What's Changed

  • Merge variable scoping into main by @yetnt in #1

Full Changelog: v4.0.0-beta.3...v4.0.0-beta.4

v4.0.0-beta.3

14 Nov 08:53

Choose a tag to compare

v4.0.0-beta.3 Pre-release
Pre-release

breaking Change : handleCommands() now takes in 2 parameteres and not a rest parameter

JS array funcs are being more wdiely used instead of for..of

Full Changelog: v4.0.0-beta.2...v4.0.0-beta.3

v4.0.0-beta.2

10 Nov 10:36

Choose a tag to compare

v4.0.0-beta.2 Pre-release
Pre-release

Same as before except i didnt actually dot he change

Call me a dumbass the way i be

Docs update to the quick example

Full Changelog: v4.0.0-beta.1...v4.0.0-beta.2

v4.0.0-beta.1

09 Nov 16:08

Choose a tag to compare

v4.0.0-beta.1 Pre-release
Pre-release

I hadda fix dis cuz my dumbahh did , and not +

Full Changelog: v4.0.0-beta.0...v4.0.0-beta.1

v4.0.0-beta.0

09 Nov 15:51

Choose a tag to compare

v4.0.0-beta.0 Pre-release
Pre-release

Log to folder

Logs now include which class it came from.

Full Changelog: v3.0.0...v4.0.0-beta.0