You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@tryforge/forgescript

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tryforge/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.

2.3.0
latest
npmnpm
Version published
Weekly downloads
3.4K
-25.85%
Maintainers
3
Weekly downloads
 
Created
Source

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

  • Installation
  • Making your first bot
  • Extensions
  • Limitations
  • Update Frequency
  • Function Documentation
  • Library Documentation

Installation

Make sure you have node.js installed, and greater than version v16.11.0. Once done, run one of the following commands in a console (from any IDE or terminal):

Main

npm i https://github.com/tryforge/ForgeScript/tree/main

Dev

npm i https://github.com/tryforge/ForgeScript/tree/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("@tryforge/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.

  • 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!
  • 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.

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

Keywords

bdfd

FAQs

Package last updated on 28 Apr 2025

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