New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

maclary

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maclary

A framework intended for making the process of creating complex Discord bots easier

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

Maclary


A framework intended for making the process of creating complex Discord bots easier


npm install maclary discord.js@dev
yarn add maclary discord.js@dev
pnpm add maclary discord.js@dev

Version Total Downloads

🤔 About

maclary is a Discord bot framework intended for making the process of creating complex Discord bots easier.

Documentation and guides coming soon

Features

  • Built-in command, listener and interaction handling
  • Create both slash and prefix commands
  • Use of preconditions and message arguments
  • Directory based subcommand creation system
  • Ability to use community-made plugins
  • Written in TypeScript

🌐 Examples

Maclary requires version >=14.7.0 of Discord.js in order to work.

NOTE: It is important that you include the main field within your package.json, this is used to find your commands, listeners and actions.

These examples show how to use maclary in TypeScript, however it will work in JavaScript with require or import.

src/index.ts

import { Client } from 'discord.js';
import { Maclary } from 'maclary';

const client = new Client({ ... });
const maclary = new Maclary({ ... });
Maclary.init(maclary, client);

client.login("DISCORD BOT TOKEN");

src/commands/echo.ts

import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
import { Command, Preconditions } from 'maclary';

function makePingMeButton(userId: string) {
    return new ActionRowBuilder().addComponents([
        new ButtonBuilder()
            .setStyle(ButtonStyle.Primary)
            .setLabel('Ping Me!')
            .setCustomId(`pingUser,${userId}`),
    ]);
}

export class EchoCommand extends Command<
    Command.Type.ChatInput,
    [Command.Kind.Slash, Command.Kind.Prefix]
> {
    public constructor() {
        super({
            type: Command.Type.ChatInput,
            kinds: [Command.Kind.Slash, Command.Kind.Prefix],
            preconditions: [Preconditions.GuildOnly],
            name: 'echo',
            description: 'Echo the input.',
            options: [
                {
                    type: Command.OptionType.String,
                    name: 'input',
                    description: 'The text to echo.',
                },
            ],
        });
    }

    public override async onSlash(input: Command.ChatInput) {
        const content = input.options.getString('input');
        const components = [makePingMeButton(input.user.id)];
        await input.reply({ content, components });
    }

    public override async onPrefix(message: Command.Message, args: Command.Arguments) {
        const content = args.rest();
        const components = [makePingMeButton(message.author.id)];
        await message.reply({ content, components });
    }
}

src/actions/pingUser.js

import { Action, Preconditions } from 'maclary';

export class PingUserAction extends Action {
    public constructor() {
        super({
            id: 'pingUser',
            preconditions: [Preconditions.GuildOnly],
        });
    }

    public override async onButton(button: Action.Button) {
        const [, userId] = button.customId.split(',');
        const user = await this.container.client.users.fetch(userId);
        await button.reply(user.toString());
    }
}

And that is it! Maclary will handle the rest.

More documention and guides will come when the website is ready.

FAQs

Package last updated on 10 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts