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

arcscord

v0.2.0

Published

A discord.js framework, slash command first and full typescript !

Downloads

619

Readme

Arcscord

npm version Discord Shield

About

Arcscord is a project for simplify creating discord bot with typescript and also some utility package used by core package !

Install

pnpm add arcscord or npm install arcscord

Example

Command

// Command declaration
import { createCommand } from "arcscord";
import { EmbedBuilder } from "discord.js";

export const avatarCommand = createCommand({
  build: {
    slash: {
      name: "avatar",
      description: "test command",
      options: {
        user: {
          type: "user",
          description: "The user",
        },
        size: {
          type: "number",
          description: "yeah",
          choices: [
            512,
            {
              name: "1024 (default)",
              value: 1024,
            },
            2048,
          ],
        } as const,
      },
    },
    user: {
      name: "avatar",
    },
  },
  run: (ctx) => {
    const user = ctx.isSlashCommand
      ? ctx.options.user || ctx.user : ctx.targetUser;

    return ctx.reply({
      embeds: [
        new EmbedBuilder()
          .setTitle(`Avatar de ${user.displayName}`)
          .setImage(user.displayAvatarURL({
            size: ctx.isSlashCommand ? ctx.options.size || 1024 : 1024,
          }) || user.defaultAvatarURL),
      ],
      ephemeral: true,
    });
  },
});

// Command register
await client.loadCommands([avatarCommand]); // need be ready

Button

// declaration button
import { buildClickableButton, createButton } from "arcscord";

export const simpleButton = createButton({
  matcher: "simple_button",
  build: () => buildClickableButton({
    label: "Simple Button",
    style: "secondary",
    customId: "simple_button",
  }),
  run: (ctx) => {
    return ctx.reply("Clicked !");
  },
});

// usage 
message.reply({
  components: [buildButtonActionRow(simpleButton.build())]
});

// register
client.loadComponents([simpleButton]);

Select Menu

// declaration
import { buildRoleSelectMenu, createSelectMenu } from "arcscord";
import { EmbedBuilder } from "discord.js";

export const roleSelectMenu = createSelectMenu({
  type: "roleSelect",
  matcher: "role_select_menu",
  build: (placeHolder) => buildRoleSelectMenu({
    placeholder: placeHolder,
    customId: "role_select_menu",
    maxValues: 1,
    minValues: 1,
  }),
  run: (ctx) => {
    const role = ctx.values[0];

    return ctx.reply({
      embeds: [
        new EmbedBuilder()
          .setTitle(`Info about role ${role.name}`)
          .setDescription(`Position: ${role.position}\nColor: ${role.color}`)
          .setColor(role.color),
      ],
    });
  },
});

// usage
message.reply({
  components: [roleSelectMenu.build("Select a role")]
});

// register
client.loadComponents([roleSelectMenu]);

Modal

// declaration
import { buildModal, createModal } from "arcscord";

export const modal = createModal({
  matcher: "modal",
  build: (title) => buildModal(title, "modal", {
    label: "name",
    style: "short",
    customId: "name",
  }, {
    label: "age",
    style: "short",
    customId: "age",
  }),
  run: (ctx) => {
    return ctx.reply(`Your name is ${ctx.values.get("name")} and you are ${ctx.values.get("age")} old !`);
  },
});

// usage
ctx.showModal(modal.build("funny"));

// register
client.loadComponents([modal]);

Event

// declaration
import { createEvent } from "arcscord";

export const messageEvent = createEvent({
  event: "messageCreate", // Djs event
  name: "messageCreate", // OPTIONAL name for logs and debug if you want custom name
  run: (ctx, msg) => {
    ctx.client.logger.info(`message send by ${msg.author.username}!`);
    return ctx.ok(true);
  },
});

// register 
client.loadEvents([messageEvent]);

Task

// declaration
import { createTask } from "arcscord";

export const cronTask = createTask({
  interval: "*/10 * * * *", // allowed : duration in ms, cron string or array of cron string
  name: "cron",
  run: (ctx) => {
    console.log(`Running cron task, next run ${ctx.nextRun.toISOString()}`);
    return ctx.ok(true);
  },
});

// register
client.loadTasks([cronTask]);

Go up