
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
SkyFold, where discord.js handlers are on another level. The best TypeScript discord.js handlers that are also super light to install.
Installing the stable version from npm.
npm i skyfold@latest discord.js
Or you can use the latest and also the dev version through npm
npm i github:aggelos-007/skyfold discord.js
After you installed the package you are ready to start you journey building your discord bot! You can initiate the client like discord.js has!
import { Client, } from "skyfold";
const client = new Client({
...ClientOptions,
});
client.login("TOKEN");
First of all, we need to load all the commands so in your main file you will have to tell SkyFold where to load commands from like this:
import { Client, } from "skyfold";
const client = new Client({
...ClientOptions,
prefixes?: string[] //Optional, required only when you want to use prefix commands
});
client.commandLoader("./commands");
client.login("TOKEN");
Now that all your commands under commands
folder will be loaded, it's time to understand how to create them!
First of all, starting with the structure, this is the accepted structure:
import { createCommand } from "skyfold";
export const data = createCommand | createCommand[]
Now gong on based the commands, here is how the createCommand function should be structured as:
Here is how the createCommand should look for prefixed commands
createCommand({
data: new PrefixedCommandBuilder()
.setName(string) // Optional only when alwaysReply is set to true
.setAliases(...string) // Optional
.setDescription(string) // Optional
.setParams(...ParamBuilder) // Optional, used only for when you want params
.setAlwaysReply(boolean)
.validateCmd(
(client: Client, msg: Message) => Promise<boolean> | boolean
), // Optional, used only when you want to run some code before running the code and if you want to prevent it from working by returning a boolean
code: (ctx: {
client: Client;
msg: Message;
args: Params[]; // This is based on the params you have put, it returns the right type
}) => Promise<void> | void;
})
Here is how ParamBuilder class is structured and all the available param types:
new ParamBuilder()
.setName(string) // Optional
.setDescription(string) // Optional
.setRest(boolean) // Required. True = returns an array of the type by getting all the args users provided | False = return the type only
.setRequired(boolean) // Optional
.setType(ParamType) // Required. Need to use ParamType[keyof ParamType]
// Optional. This method is used to handle errors whenever users fail to return a valid type or don't provide a required param
.setErrorHandler(
(client: Client, msg: Message, errorType: "missing" | "wrongType") => Promise<void> | void
)
//ParamType Enum
enum ParamType {
String
Number
User
Member
Channel
Role
};
Here is how the createCommand should look for slash commands
createCommand({
data: new SlashCommandBuilder() // This is the same with the discord.js builder but with 1 extra method
.onlyForGuilds(...string) // Optional, makes the slash command guild only and not as global
code: (ctx: {
client: Client;
int: ChatInputCommandInteraction
}) => Promise<void> | void;
})
Here is how the createCommand should look for interaction commands
createCommand({
data: new InteractionCommandBuilder()
.setName(name) // Optional
.setType(InteractionType) //Optional, default: InteractionType.All. Need to use InteractionType[keyof InteractionType]
code: (ctx: {
client: Client;
int: Interaction; // This interaction type changes to the type you provide in the builder
}) => Promise<void> | void;
})
// InteractionType enum
enum InteractionType {
All
Modal
Button
AutoComplete
RoleSelectMenu
UserSelectMenu
StringSelectMenu
ChannelSelectMenu
MentionableSelectMenu
};
Here is how the createCommand should look for context menu commands
createCommand({
data: new ContextMenuCommandBuilder() // This is the same with the discord.js builder but with 1 extra method
.onlyForGuilds(...string) // Optional, makes the context menu command guild only and not as global
code: (ctx: {
client: Client;
int: ContextMenuCommandInteraction;
}) => Promise<void> | void;
})
First of all, we need to load all the events so in your main file you will have to tell SkyFold where to load commands from like this:
import { Client, } from "skyfold";
const client = new Client({
...ClientOptions
});
client.eventLoader("./events");
client.login("TOKEN");
Now that all your events under events
folder will be loaded, it's time to understand how to create them!
Here is how you should be aiming to create your events:
import { createEvent } from "skyfold";
export const data = createEvents({
name: keyof ClientEvents, // Required
once: boolean, // Optional, default: true
code: (client: Client, ...args: ClientEvents[EventName]) => void | Promise<void>; // Required
});
Do you want to change the way all the interactions are handled? Here is everything you need to know about:
const client = new Client({
...ClientOptions,
customHandlers: {
prefix?: (client: Client, msg: Message) => Promise<void> | void;
slash?: (client: Client, int: ChatInputCommandInteraction) => Promise<void> | void;
interactions?: (client: Client, int: Interaction) => Promise<void> | void;
};
})
This package was made with love by this guy <3
Agglos-007 |
FAQs
Yet another discord.js handlers to make your life easier
We found that skyfold demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.