Gathering detailed insights and metrics for @kaname-png/revoltx
Gathering detailed insights and metrics for @kaname-png/revoltx
Gathering detailed insights and metrics for @kaname-png/revoltx
Gathering detailed insights and metrics for @kaname-png/revoltx
Revoltx is a Framework for revolt.js to create awesome bots.
npm install @kaname-png/revoltx
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (99.77%)
JavaScript (0.23%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
12 Stars
480 Commits
2 Forks
2 Watchers
12 Branches
2 Contributors
Updated on Jun 03, 2025
Latest Version
2.0.6
Package Id
@kaname-png/revoltx@2.0.6
Unpacked Size
254.88 kB
Size
54.57 kB
File Count
172
NPM Version
9.8.1
Node Version
20.6.0
Published on
Sep 12, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
11
28
With RevoltX you have at your disposal the creation of highly typed, secure and easy to make bots with a wide variety of tools and utilities available.
Now you can continue installing the necessary packages.
npm i @kaname-png/revoltx revolt.js
Or
yarn add @kaname-png/revoltx revolt.js
This is how the client is created and the bot is started.
1// client.js 2import { Client } from '@kaname-png/revoltx'; 3import { join } from 'path'; 4import { fileURLToPath } from 'url'; 5 6const start = () => { 7 const client = new Client({ prefix: '!' }); 8 await client.login('<BOT_TOKEN>'); 9}; 10 11void start();
Now you can start bot as follows:
node --experimental-specifier-resolution=node client.js
To set the path to the commands, listeners, etc. you need to indicate the path to your "main.js" file (the file which starts your bot) in the "main" property of your package.json
file.
Remember that the name of your main file
(main.js)
is up to you.
For JavaScript it should be for example:
1{ 2 "name": "my-awesome-bot", 3 "version": "1.0.0", 4 "main": "src/main.js" 5}
For TypeScript it should be for example:
1{ 2 "name": "my-awesome-bot", 3 "version": "1.0.0", 4 "main": "dist/main.js" 5}
Once the client is created and instantiated, it is time to configure where all your commands, listeners, arguments, etc. are located.
1import { Client } from '@kaname-png/revoltx'; 2import { join } from 'path'; 3import { fileURLToPath } from 'url'; 4 5const start = () => { 6 const client = new Client({ prefix: '!' }); 7 await client.login('<BOT_TOKEN>'); 8};
Our project should have a folder structure like this.
├───commands
│ └───help.js
└───main.js
Basic structure of a basic command.
Commands are actions that users can request to the bot by means of a prefix and command name, e.g.: n!help
.
1// commands/help.ts 2import { Command, CommandOptions, PieceContext } from '@kaname-png/revoltx'; 3import type { Message } from 'revolt.js'; 4 5export class HelpCommand extends Command { 6 // If you need to add extra options to the command, you can do it in the constructor, it is not required if you don't need to add options. 7 constructor(context: PieceContext, options: CommandOptions) { 8 super(context, { 9 ...options, 10 alias: ['helpme'] 11 /* optional commands options */ 12 }); 13 } 14 15 public async run(message: Message) { 16 return message.reply('@kaname-png/revoltx'); 17 } 18}
Basic structure of a basic listener.
The listeners have the function of listening to events that the client emits by default, but you can assign the emitter you need and listen to the events of that emitter.
1// listener/message.ts 2import { Listener, ListenerOptions ClientEvents, PieceContext } from '@kaname-png/revoltx'; 3import type { Message } from 'revolt.js'; 4 5export class MessageListener extends Listener { 6 // You can set the event name you need. 7 constructor(context: PieceContext, options: ListenerOptions) { 8 super(context, { 9 ...options, 10 event: ClientEvents.MessageCreate 11 /* optional listeners options */ 12 }); 13 } 14 15 public async run(message: Message) { 16 return message.reply('@kaname-png/revoltx'); 17 } 18}
Basic structure of a basic argument. Arguments are parameters that the bot receives from the message sent by the user. This argument system allows to use arguments dynamically as needed, and not only by configuring the command options.
1// arguments/serverOwner.ts 2import { Argument, ArgumentOptions ArgumentResult, PieceContext } from '../lib/structures/argument'; 3import type { ArgumentContext } from '../utils/interfaces/argument'; 4 5// <boolean> is for TypeScript users only. 6export class ServerOwnerArgument extends Argument<boolean> { 7 // Asign name of argument 8 public constructor(context: PieceContext, options: ArgumentOptions) { 9 super(context, { 10 ...options, 11 name: 'ServerOwner' 12 /* optional arguments options */ 13 }); 14 } 15 16 public run(parameter: string, context: ArgumentContext): ArgumentResult<boolean> { 17 const resolved = message.member?.server?.owner === parameter; 18 if (!resolved) return this.ok(true); 19 20 return this.error({ 21 parameter, 22 identifier: resolved.error, 23 message: 'The argument did not resolve to server owner.', 24 context 25 }); 26 } 27} 28 29// For TypeScript users only. 30declare module '@kaname-png/revoltx' { 31 interface ArgType { 32 // The type returned by the this.ok() method; 33 ServerOwner: boolean; 34 } 35} 36 37// Command Usage 38// User Input: n!server @kaname-png 39import { Args, Command } from '@kaname-png/revoltx'; 40import type { Message } from 'revolt.js'; 41 42export class ServerCommand extends Command { 43 public run(message: Message, args: Args) { 44 const owner = await args.pick('ServerOwner'); 45 return message.channel?.sendMessage(owner ? 'You are server owner.' : 'You are not the owner of the server.'); 46 } 47}
Basic structure of a basic precondition.
1// preconditions/nsfw.ts 2import type { PieceContext, Precondition, PreconditionOptions, PreconditionResult, Identifiers } from '@kaname-png/revoltx'; 3import type { Message } from 'revolt.js'; 4 5export class NSFWPrecondition extends Precondition { 6 public constructor(context: PieceContext, options: PreconditionOptions) { 7 super(context, { 8 ...options, 9 name: 'NSFW' 10 /* optional preconditions options */ 11 }); 12 } 13 14 public run(message: Message): PreconditionResult { 15 return message.channel?.nsfw === true 16 ? this.ok() 17 : this.error({ identifier: Identifiers.PreconditionsNsfw, message: 'You cannot run this command outside NSFW channels.' }); 18 } 19} 20 21// For TypeScript users only. 22declare module '@kaname-png/revoltx' { 23 interface Preconditions { 24 // Name of precondition 25 NSFW: never; 26 } 27}
This also applies to arguments, listeners, preconditions, etc.
TypeScript code
1// commands/help.ts 2import { Command, CommandOptions, PieceContext } from '@kaname-png/revoltx'; 3import type { Message } from 'revolt.js'; 4 5export class HelpCommand extends Command { 6 // If you need to add extra options to the command, you can do it in the constructor, it is not required if you don't need to add options. 7 constructor(context: PieceContext, options: CommandOptions) { 8 super(context, { 9 ...options 10 /* optional commands options */ 11 }); 12 } 13 14 public run(message: Message) { 15 return message.reply('@kaname-png/revoltx'); 16 } 17}
JavaScript code
1// commands/help.js 2import { Command } from '@kaname-png/revoltx'; 3 4export class HelpCommand extends Command { 5 // If you need to add extra options to the command, you can do it in the constructor, it is not required if you don't need to add options. 6 constructor(context, options) { 7 super(context, { 8 ...options 9 /* optional commands options */ 10 }); 11 } 12 13 run(message) { 14 return message.reply('@kaname-png/revoltx'); 15 } 16}
Thanks goes to these wonderful people (emoji key):
Kaname 🐛 💻 📖 🤔 🚧 📆 👀 |
This project follows the all-contributors specification. Contributions of any kind welcome!
No vulnerabilities found.
No security vulnerabilities found.