npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dart14

v1.1.5

Published

Dart commands has come back and updated to discord.js v14, including new features, wayyy less bugs (we're aware the original was very buggy), everything has been fixed and optimized for your needs to quickly create bots on the fly.

Downloads

13

Readme

Dart Commands v14

Dart commands has come back and updated to discord.js v14, including new features, wayyy less bugs (we're aware the original was very buggy), everything has been fixed and optimized for your needs to quickly create bots on the fly.

Starting your project

Dart can be used in TypeScript, TypeScript is recommended and will be used for examples throughout docs.

import DartCommands from 'dart14';
import { Client, IntentsBitFields } from "discord.js";
import path from "path";

// Events
import MyEvent from "./events/MyEvent";

const client = new Client({
  intents: [
    IntentsBitField.Flags.Guilds,
    IntentsBitField.Flags.GuildMessages,
    IntentsBitField.Flags.MessageContent,
  ],
});

client.on("ready", () => {
    new DartCommands({
        client,
        bot: {
            commandsDir: path.join(__dirname, "commands"),
            prefix: "!", // Optional, default is "!"
            testServers: ["your server"], // Optional: Used for commands to only be ran in certain servers
        }
        events: { // Optional
            MyEvent
        },
        defaultCommands: { // Optional: Customize what the default commands can do
            command: { // This can be any default command that ships with Dart, e.g "prefix", you can also extract this to a command file and import it.
                names: ["prefix", "p"], // Would add "p" as a command alias
                description: "Change the description if you like",
                permission: "BanMembers", // Even the permission
                execute() { // You can even change what the command does!
                    return "No prefix changing!"
                }
            }
        },
        mongo: { // Optional
            uri: "mongodb://127.0.0.1:27017/myDb",
            dbOptions: {} // Optional configuration
        },
        languageSettings: { // Optional, change what messages are sent that are unchangeable within the library, e.g. permission error messages
            errors: {
                noPermission(command) {
                    return "You don't have permission!" // Or you can return an embed
                }
            }
        }
    })
})

client.login("bot token")

Creating your first command

commands/ping.ts

import { Command, CommandType } from 'dart14';
import { EmbedBuilder, Colors } from 'discord.js';

export default {
    description: "Returns pong!",
    type: CommandType.Both, // CommandTyoe.Legacy, CommandType.Slash
    names: ["ping", "p"], // Optional: Name of command and aliases
    permission: "Administrator",
    testOnly: true, // Optional: Can only be used in test servers
    options: [] // Optional: Used for slash commands
    execute({
        message,
        interaction,
        member,
        guild,
        instance,
        client,
        author,
        channel
    }) {
        return "Pong!";
        // Or you can reply with embeds
        return new EmbedBuilder({
            title: "Pong!",
            color: Colors.Green
        });
        // Or you can return an object!
        return {
            content: "Pong 1!",
            embeds: [
                new EmbedBuilder({
                    title: "Pong 2!",
                    color: Colors.Green
                });
            ],
            components: [your components]
        }
        // or if you'd like, return nothing
        return;
    }
} as Command

Creating the event file

Events will not automatically load, this is due to performace. You will need to import your events in the main index file for your bot.

events/MyEvent.ts

import { Client, Message } from "discord.js";
import DartCommands from "dart14";

export default (client: Client<boolean>, instance: DartCommands) => {
  client.on("messageCreate", (message: Message<boolean>) => {
    console.log(message.content);
  });
};

And that's it! You can now productively use DartCommands!