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

forgescript

v1.3.0

Published

ForgeScript is a comprehensive package that empowers you to effortlessly interact with Discord's API. It ensures scripting remains easy to learn and consistently effective.

Downloads

1,309

Readme

ForgeScript

ForgeScript is a comprehensive package that empowers you to effortlessly interact with Discord's API. It ensures scripting remains easy to learn and consistently effective.

Index

  1. Installation
  2. Making your first bot
    1. Client Initialization
    2. Registering Commands
      1. Basic registering
      2. Registering from a root folder
  3. Extensions
  4. Limitations
  5. Update Frequency
  6. Function Documentation
  7. Library Documentation

Installation

Make sure you have node.js installed, and greater than version v16.11.0. Once done, run the next command in a folder (from any IDE or terminal):

npm i https://github.com/tryforge/ForgeScript.git

If installing this repository instead of npm, you must have TypeScript as dependency (npm i typescript --save-dev)

Making your first Bot

This section will guide you through initializing a client and loading commands from a folder, as well as logging your bot into discord.

Client Initialization

We will write the following for a basic bot initialization, in a index.js file:

const { ForgeClient } = require("forgescript")

const client = new ForgeClient({
    intents: [
        "GuildMessages",
        "Guilds",
        "MessageContent" // This intent is privileged, must be whitelisted in dev portal, in your application.
    ],
    events: [
        "messageCreate",
        "ready"
    ], // Events our bot will act on
    prefixes: [
        "!",
        "?"
    ] // The prefixes to use for our bot!
})

client.login("token")

This will be enough to put our bot on.

Registering commands

Registering commands is the way to go when we want something to happen on certain events.

Basic registering

Let's write this after our client initialization code:

client.commands.add({
    name: "user", // Not defining this creates a command that will be executed for every event fired of given type
    code: `Your name is $username!`,
    type: "messageCreate" // The event to act on
})

And this will register a command with name user that will return the name of the user that executed this command.

Registering from a root folder

The previous way to register commands can fill our index file with a lot of junk code, so there's a way to put files with commands in folders and load them from the index file.

  1. Create a folder, with any name, and a file inside it, name it whatever you want (must end with .js) and write the following in it:
    module.exports = {
        name: "user",
        type: "messageCreate",
        code: `Your name is $username!`
    }
    This is essentially the same as the previous command, but will be loaded from a folder!
  2. Now, let's go back to our index file and write the following after client initialization (Make sure you've erased the code to register a command from index file):
    client.commands.load("./<folder>")
    Replace <folder> with the folder name you used, and every file residing in the root folder (the tree doesn't matter as long as the file is in the folder) will be loaded into your bot!

Limitations

There's currently no known limitation.

Note this library reads codes from TOP to BOTTOM, and never the opposite.