Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@tryforge/forgescript
Advanced tools
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.
Readme
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.
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
)
This section will guide you through initializing a client and loading commands from a folder, as well as logging your bot into discord.
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 is the way to go when we want something to happen on certain events.
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.
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.
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!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!There's currently no known limitation.
Note this library reads codes from TOP to BOTTOM, and never the opposite.
FAQs
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.
The npm package @tryforge/forgescript receives a total of 7 weekly downloads. As such, @tryforge/forgescript popularity was classified as not popular.
We found that @tryforge/forgescript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.