revbot.js 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,133 +1,156 @@
1
- # revbot.js
2
-
3
- # Note: this package is currently in the early stages of development and testing
4
-
5
- `revbot.js` is a Node.js library for building bots on the Revolt platform. It provides an easy-to-use interface for interacting with Revolt's API, managing events, and handling various bot functionalities. NOTE: node 21 is required to run this
6
- [revolt server](https://rvlt.gg/2NcCgYZ0) [docs](https://jade3375.github.io/revbot.js/)
7
-
8
- ## Installation
9
-
10
- ```bash
11
- npm install revbot.js
12
- ```
13
-
14
- or
15
-
16
- ```bash
17
- yarn add revbot.js
18
- ```
19
-
20
- ## Basic Setup
21
-
22
- Below is an example of how to set up a basic bot using `revbot.js`:
23
-
24
- ### Example Code
25
-
26
- ```ts
27
- import { client } from "revbot.js";
28
-
29
- const bot = new client({});
30
-
31
- bot.on("ready", () => {
32
- console.log("Bot is ready!");
33
- });
34
-
35
- bot.on("message", (message) => {
36
- if (message.content === "ping") {
37
- message.reply("pong");
38
- }
39
- });
40
-
41
- bot.login("YOUR_BOT_TOKEN");
42
- ```
43
-
44
- ## Features
45
-
46
- - Event-based architecture for handling messages, server updates, and more.
47
- - Easy-to-use managers for channels, servers, users, and roles.
48
-
49
- ## Development
50
-
51
- To contribute or modify the library:
52
-
53
- 1. Clone the repository:
54
-
55
- ```bash
56
- git clone https://github.com/Jade3375/revbot.js.git
57
- cd revbot.js
58
- ```
59
-
60
- 2. Install dependencies:
61
-
62
- ```bash
63
- yarn install
64
- ```
65
-
66
- 3. Build the project:
67
-
68
- ```bash
69
- yarn build
70
- ```
71
-
72
- ## Contribution
73
-
74
- We welcome contributions to `revbot.js`! To contribute, follow these steps:
75
-
76
- 1. **Fork the Repository**
77
- Go to the [repository](https://github.com/Jade3375/revbot.js) and click the "Fork" button to create your own copy.
78
-
79
- 2. **Clone Your Fork**
80
- Clone your forked repository to your local machine:
81
-
82
- ```bash
83
- git clone https://github.com/your-username/revbot.js
84
- cd revbot.js
85
- ```
86
-
87
- 3. **Create a Branch**
88
- Create a new branch for your feature or bug fix:
89
-
90
- ```bash
91
- git checkout -b feature-or-bugfix-name
92
- ```
93
-
94
- 4. **Make Changes**
95
- Implement your changes or fixes in the codebase.
96
-
97
- 5. **Test Your Changes**
98
- Ensure your changes work as expected by running the project and any relevant tests:
99
-
100
- ```bash
101
- yarn test
102
- ```
103
-
104
- 6. **Commit Your Changes**
105
- Commit your changes with a descriptive message:
106
-
107
- ```bash
108
- git add .
109
- git commit -m "Description of your changes"
110
- ```
111
-
112
- 7. **Push Your Branch**
113
- Push your branch to your forked repository:
114
-
115
- ```bash
116
- git push origin feature-or-bugfix-name
117
- ```
118
-
119
- 8. **Open a Pull Request**
120
- Go to the original repository and open a pull request from your branch. Provide a clear description of your changes and why they should be merged.
121
-
122
- ### Guidelines
123
-
124
- - Follow the existing code style and structure.
125
- - Write clear and concise commit messages.
126
- - Add or update documentation if necessary.
127
- - Ensure your changes do not break existing functionality.
128
-
129
- Thank you for contributing to `revbot.js`!
130
-
131
- ## License
132
-
133
- This project is licensed under the MIT License.
1
+ # revbot.js
2
+
3
+ # Note: this package is currently in the early stages of development and testing
4
+
5
+ `revbot.js` is a Node.js library for building bots on the Revolt platform. It provides an easy-to-use interface for interacting with Revolt's API, managing events, and handling various bot functionalities. NOTE: node 21 is required to run this
6
+ [revolt server](https://rvlt.gg/2NcCgYZ0) [docs](https://jade3375.github.io/revbot.js/)
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install revbot.js
12
+ ```
13
+
14
+ or
15
+
16
+ ```bash
17
+ yarn add revbot.js
18
+ ```
19
+
20
+ ## Basic Setup
21
+
22
+ Below is an example of how to set up a basic bot using `revbot.js`:
23
+
24
+ ### Example Code
25
+
26
+ ### typescript
27
+
28
+ ```ts
29
+ import { client, MessageStruct } from "revbot.js";
30
+
31
+ const bot = new client({});
32
+
33
+ bot.on("ready", () => {
34
+ console.log("Bot is ready!");
35
+ });
36
+
37
+ bot.on("message", (message: MessageStruct) => {
38
+ if (message.content === "ping") {
39
+ message.reply("pong");
40
+ }
41
+ });
42
+
43
+ bot.login("YOUR_BOT_TOKEN");
44
+ ```
45
+
46
+ ### javascript
47
+
48
+ ```js
49
+ const { client } = require("revbot.js");
50
+
51
+ const bot = new client({});
52
+
53
+ bot.on("ready", () => {
54
+ console.log("Bot is ready!");
55
+ });
56
+
57
+ bot.on("message", (message) => {
58
+ if (message.content === "ping") {
59
+ message.reply("pong");
60
+ }
61
+ });
62
+
63
+ bot.login("YOUR_BOT_TOKEN");
64
+ ```
65
+
66
+ ## Features
67
+
68
+ - Event-based architecture for handling messages, server updates, and more.
69
+ - Easy-to-use managers for channels, servers, users, and roles.
70
+ - Experimental support for 3rd party instances using backend version 0.7 +
71
+
72
+ ## Development
73
+
74
+ To contribute or modify the library:
75
+
76
+ 1. Clone the repository:
77
+
78
+ ```bash
79
+ git clone https://github.com/Jade3375/revbot.js.git
80
+ cd revbot.js
81
+ ```
82
+
83
+ 2. Install dependencies:
84
+
85
+ ```bash
86
+ yarn install
87
+ ```
88
+
89
+ 3. Build the project:
90
+
91
+ ```bash
92
+ yarn build
93
+ ```
94
+
95
+ ## Contribution
96
+
97
+ We welcome contributions to `revbot.js`! To contribute, follow these steps:
98
+
99
+ 1. **Fork the Repository**
100
+ Go to the [repository](https://github.com/Jade3375/revbot.js) and click the "Fork" button to create your own copy.
101
+
102
+ 2. **Clone Your Fork**
103
+ Clone your forked repository to your local machine:
104
+
105
+ ```bash
106
+ git clone https://github.com/your-username/revbot.js
107
+ cd revbot.js
108
+ ```
109
+
110
+ 3. **Create a Branch**
111
+ Create a new branch for your feature or bug fix:
112
+
113
+ ```bash
114
+ git checkout -b feature-or-bugfix-name
115
+ ```
116
+
117
+ 4. **Make Changes**
118
+ Implement your changes or fixes in the codebase.
119
+
120
+ 5. **Test Your Changes**
121
+ Ensure your changes work as expected by running the project and any relevant tests:
122
+
123
+ ```bash
124
+ yarn test
125
+ ```
126
+
127
+ 6. **Commit Your Changes**
128
+ Commit your changes with a descriptive message:
129
+
130
+ ```bash
131
+ git add .
132
+ git commit -m "Description of your changes"
133
+ ```
134
+
135
+ 7. **Push Your Branch**
136
+ Push your branch to your forked repository:
137
+
138
+ ```bash
139
+ git push origin feature-or-bugfix-name
140
+ ```
141
+
142
+ 8. **Open a Pull Request**
143
+ Go to the original repository and open a pull request from your branch. Provide a clear description of your changes and why they should be merged.
144
+
145
+ ### Guidelines
146
+
147
+ - Follow the existing code style and structure.
148
+ - Write clear and concise commit messages.
149
+ - Add or update documentation if necessary.
150
+ - Ensure your changes do not break existing functionality.
151
+
152
+ Thank you for contributing to `revbot.js`!
153
+
154
+ ## License
155
+
156
+ This project is licensed under the MIT License.
package/dist/index.d.mts CHANGED
@@ -72,6 +72,9 @@ declare class UUID extends null {
72
72
  static timestampOf(id: string): Date;
73
73
  }
74
74
 
75
+ /** A type that can be a BitField, number, string, or an array of these types.
76
+ * @private
77
+ */
75
78
  type BitFieldResolvable = BitField | number | string | BitFieldResolvable[];
76
79
  /**
77
80
  * Represents a bitfield that can be used to manage flags or permissions.
@@ -135,6 +138,7 @@ declare class RestClient {
135
138
  * @returns The API response.
136
139
  */
137
140
  private request;
141
+ getConfig(): Promise<void>;
138
142
  private retryRequest;
139
143
  /**
140
144
  * GET request.
@@ -355,6 +359,7 @@ declare abstract class BaseClient extends EventEmitter {
355
359
 
356
360
  /**
357
361
  * Enum representing the client events that can be emitted.
362
+ * @private
358
363
  */
359
364
  declare enum Events {
360
365
  CHANNEL_CREATE = "channelCreate",
@@ -387,6 +392,7 @@ declare enum Events {
387
392
  }
388
393
  /**
389
394
  * Enum representing the WebSocket events used for communication.
395
+ * @private
390
396
  */
391
397
  declare enum WSEvents {
392
398
  AUTHENTICATE = "Authenticate",
@@ -434,12 +440,8 @@ declare enum ChannelTypes {
434
440
  * The default options for configuring the client.
435
441
  */
436
442
  declare const DEFAULT_CLIENT_OPTIONS: clientOptions;
437
- /** The WebSocket URL for connecting to the Revolt API. */
438
- declare const wsUrl = "wss://ws.revolt.chat?version=1&format=json";
439
- /** The base API URL for interacting with the Revolt API. */
440
- declare const apiUrl = "https://api.revolt.chat";
441
- /** The base URL for the Revolt CDN, used for serving static assets. */
442
- declare const cdnUrl = "https://cdn.revoltusercontent.com";
443
+ /** The base API URL for interacting with the Stoat API. */
444
+ declare const apiUrl = "https://api.stoat.chat";
443
445
  /** The system user ID used for identifying system messages. */
444
446
  declare const SYSTEM_USER_ID: string;
445
447
 
@@ -1668,6 +1670,10 @@ declare class NotesChannel extends Channel implements TextBasedChannel {
1668
1670
  get user(): User;
1669
1671
  }
1670
1672
 
1673
+ /**
1674
+ * Represents a channel in the API.
1675
+ * @private
1676
+ */
1671
1677
  type APIServerChannel = Extract<Channel$1, {
1672
1678
  channel_type: "TextChannel" | "VoiceChannel";
1673
1679
  }>;
@@ -1690,6 +1696,8 @@ declare class ServerChannel extends Channel {
1690
1696
  description: string | null;
1691
1697
  /** The icon of the channel, or `null` if none is set. */
1692
1698
  icon: Attachment | null;
1699
+ /** Manages the messages in this Server channel. */
1700
+ messages: MessageManager;
1693
1701
  /** The permission overwrites for the channel. */
1694
1702
  overwrites: Map<string, Overwrite>;
1695
1703
  /** Whether the channel is marked as NSFW (Not Safe For Work). */
@@ -1728,6 +1736,18 @@ declare class ServerChannel extends Channel {
1728
1736
  * @returns {Server} The server instance.
1729
1737
  */
1730
1738
  get server(): Server;
1739
+ /**
1740
+ * Sends a message to this Server channel.
1741
+ *
1742
+ * @param {MessageOptions | string} options - The message content or options for the message.
1743
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1744
+ *
1745
+ * @example
1746
+ * ```typescript
1747
+ * await serverChannel.send("Hello, world!");
1748
+ * ```
1749
+ */
1750
+ send(options: MessageOptions | string): Promise<MessageStruct>;
1731
1751
  /**
1732
1752
  * Retrieves the category this channel belongs to, if any.
1733
1753
  *
@@ -2275,6 +2295,11 @@ declare class client extends BaseClient {
2275
2295
  user: ClientUser | null;
2276
2296
  /** The timestamp when the client became ready, or `null` if not ready. */
2277
2297
  readyAt: Date | null;
2298
+ /**
2299
+ * Initializes the client.
2300
+ * @private
2301
+ */
2302
+ init(): Promise<void>;
2278
2303
  /**
2279
2304
  * Gets the timestamp when the client became ready.
2280
2305
  *
@@ -2677,4 +2702,4 @@ declare class ServerMemberManager extends BaseManager<ServerMember, Member> {
2677
2702
  resolveId(member: ServerMemberResolvable): string | null;
2678
2703
  }
2679
2704
 
2680
- export { Attachment, type BadgeString, Badges, type BadgesResolvable, Base, BaseManager, BitField, type BitFieldResolvable, Category, Channel, ChannelManager, ChannelPermissions, type ChannelPermissionsResolvable, type ChannelPermissionsString, type ChannelResolvable, ChannelTypes, type CreateChannelOptions, DEFAULT_CLIENT_OPTIONS, DEFAULT_PERMISSION_DM, DMChannel, type EditServerMemberOptions, type EditServerOptions, type Embed, type EmbedImage, type EmbedSpecial, type EmbedVideo, Emoji, Events, FullPermissions, GroupChannel, Invite, Mentions, type MessageEditOptions, MessageEmbed, MessageManager, type MessageOptions, type MessageQueryOptions, type MessageReply, type MessageResolvable, type MessageSearchOptions, MessageStruct, NotesChannel, type Overwrite, type PartialObject, Presence, Role, RoleManager, type RoleResolvable, SYSTEM_USER_ID, Server, ServerChannel, ServerChannelManager, type ServerChannelResolvable, ServerManager, ServerMember, ServerMemberManager, type ServerMemberResolvable, ServerPermissions, type ServerPermissionsResolvable, type ServerPermissionsString, type ServerResolvable, Status, TextChannel, UUID, User, UserManager, UserPermissions, type UserPermissionsResolvable, type UserPermissionsString, type UserResolvable, VoiceChannel, WSEvents, apiUrl, cdnUrl, client, wsUrl };
2705
+ export { Attachment, type BadgeString, Badges, type BadgesResolvable, Base, BaseManager, BitField, type BitFieldResolvable, Category, Channel, ChannelManager, ChannelPermissions, type ChannelPermissionsResolvable, type ChannelPermissionsString, type ChannelResolvable, ChannelTypes, type CreateChannelOptions, DEFAULT_CLIENT_OPTIONS, DEFAULT_PERMISSION_DM, DMChannel, type EditServerMemberOptions, type EditServerOptions, type Embed, type EmbedImage, type EmbedSpecial, type EmbedVideo, Emoji, Events, FullPermissions, GroupChannel, Invite, Mentions, type MessageEditOptions, MessageEmbed, MessageManager, type MessageOptions, type MessageQueryOptions, type MessageReply, type MessageResolvable, type MessageSearchOptions, MessageStruct, NotesChannel, type Overwrite, type PartialObject, Presence, Role, RoleManager, type RoleResolvable, SYSTEM_USER_ID, Server, ServerChannel, ServerChannelManager, type ServerChannelResolvable, ServerManager, ServerMember, ServerMemberManager, type ServerMemberResolvable, ServerPermissions, type ServerPermissionsResolvable, type ServerPermissionsString, type ServerResolvable, Status, TextChannel, UUID, User, UserManager, UserPermissions, type UserPermissionsResolvable, type UserPermissionsString, type UserResolvable, VoiceChannel, WSEvents, apiUrl, client };
package/dist/index.d.ts CHANGED
@@ -72,6 +72,9 @@ declare class UUID extends null {
72
72
  static timestampOf(id: string): Date;
73
73
  }
74
74
 
75
+ /** A type that can be a BitField, number, string, or an array of these types.
76
+ * @private
77
+ */
75
78
  type BitFieldResolvable = BitField | number | string | BitFieldResolvable[];
76
79
  /**
77
80
  * Represents a bitfield that can be used to manage flags or permissions.
@@ -135,6 +138,7 @@ declare class RestClient {
135
138
  * @returns The API response.
136
139
  */
137
140
  private request;
141
+ getConfig(): Promise<void>;
138
142
  private retryRequest;
139
143
  /**
140
144
  * GET request.
@@ -355,6 +359,7 @@ declare abstract class BaseClient extends EventEmitter {
355
359
 
356
360
  /**
357
361
  * Enum representing the client events that can be emitted.
362
+ * @private
358
363
  */
359
364
  declare enum Events {
360
365
  CHANNEL_CREATE = "channelCreate",
@@ -387,6 +392,7 @@ declare enum Events {
387
392
  }
388
393
  /**
389
394
  * Enum representing the WebSocket events used for communication.
395
+ * @private
390
396
  */
391
397
  declare enum WSEvents {
392
398
  AUTHENTICATE = "Authenticate",
@@ -434,12 +440,8 @@ declare enum ChannelTypes {
434
440
  * The default options for configuring the client.
435
441
  */
436
442
  declare const DEFAULT_CLIENT_OPTIONS: clientOptions;
437
- /** The WebSocket URL for connecting to the Revolt API. */
438
- declare const wsUrl = "wss://ws.revolt.chat?version=1&format=json";
439
- /** The base API URL for interacting with the Revolt API. */
440
- declare const apiUrl = "https://api.revolt.chat";
441
- /** The base URL for the Revolt CDN, used for serving static assets. */
442
- declare const cdnUrl = "https://cdn.revoltusercontent.com";
443
+ /** The base API URL for interacting with the Stoat API. */
444
+ declare const apiUrl = "https://api.stoat.chat";
443
445
  /** The system user ID used for identifying system messages. */
444
446
  declare const SYSTEM_USER_ID: string;
445
447
 
@@ -1668,6 +1670,10 @@ declare class NotesChannel extends Channel implements TextBasedChannel {
1668
1670
  get user(): User;
1669
1671
  }
1670
1672
 
1673
+ /**
1674
+ * Represents a channel in the API.
1675
+ * @private
1676
+ */
1671
1677
  type APIServerChannel = Extract<Channel$1, {
1672
1678
  channel_type: "TextChannel" | "VoiceChannel";
1673
1679
  }>;
@@ -1690,6 +1696,8 @@ declare class ServerChannel extends Channel {
1690
1696
  description: string | null;
1691
1697
  /** The icon of the channel, or `null` if none is set. */
1692
1698
  icon: Attachment | null;
1699
+ /** Manages the messages in this Server channel. */
1700
+ messages: MessageManager;
1693
1701
  /** The permission overwrites for the channel. */
1694
1702
  overwrites: Map<string, Overwrite>;
1695
1703
  /** Whether the channel is marked as NSFW (Not Safe For Work). */
@@ -1728,6 +1736,18 @@ declare class ServerChannel extends Channel {
1728
1736
  * @returns {Server} The server instance.
1729
1737
  */
1730
1738
  get server(): Server;
1739
+ /**
1740
+ * Sends a message to this Server channel.
1741
+ *
1742
+ * @param {MessageOptions | string} options - The message content or options for the message.
1743
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1744
+ *
1745
+ * @example
1746
+ * ```typescript
1747
+ * await serverChannel.send("Hello, world!");
1748
+ * ```
1749
+ */
1750
+ send(options: MessageOptions | string): Promise<MessageStruct>;
1731
1751
  /**
1732
1752
  * Retrieves the category this channel belongs to, if any.
1733
1753
  *
@@ -2275,6 +2295,11 @@ declare class client extends BaseClient {
2275
2295
  user: ClientUser | null;
2276
2296
  /** The timestamp when the client became ready, or `null` if not ready. */
2277
2297
  readyAt: Date | null;
2298
+ /**
2299
+ * Initializes the client.
2300
+ * @private
2301
+ */
2302
+ init(): Promise<void>;
2278
2303
  /**
2279
2304
  * Gets the timestamp when the client became ready.
2280
2305
  *
@@ -2677,4 +2702,4 @@ declare class ServerMemberManager extends BaseManager<ServerMember, Member> {
2677
2702
  resolveId(member: ServerMemberResolvable): string | null;
2678
2703
  }
2679
2704
 
2680
- export { Attachment, type BadgeString, Badges, type BadgesResolvable, Base, BaseManager, BitField, type BitFieldResolvable, Category, Channel, ChannelManager, ChannelPermissions, type ChannelPermissionsResolvable, type ChannelPermissionsString, type ChannelResolvable, ChannelTypes, type CreateChannelOptions, DEFAULT_CLIENT_OPTIONS, DEFAULT_PERMISSION_DM, DMChannel, type EditServerMemberOptions, type EditServerOptions, type Embed, type EmbedImage, type EmbedSpecial, type EmbedVideo, Emoji, Events, FullPermissions, GroupChannel, Invite, Mentions, type MessageEditOptions, MessageEmbed, MessageManager, type MessageOptions, type MessageQueryOptions, type MessageReply, type MessageResolvable, type MessageSearchOptions, MessageStruct, NotesChannel, type Overwrite, type PartialObject, Presence, Role, RoleManager, type RoleResolvable, SYSTEM_USER_ID, Server, ServerChannel, ServerChannelManager, type ServerChannelResolvable, ServerManager, ServerMember, ServerMemberManager, type ServerMemberResolvable, ServerPermissions, type ServerPermissionsResolvable, type ServerPermissionsString, type ServerResolvable, Status, TextChannel, UUID, User, UserManager, UserPermissions, type UserPermissionsResolvable, type UserPermissionsString, type UserResolvable, VoiceChannel, WSEvents, apiUrl, cdnUrl, client, wsUrl };
2705
+ export { Attachment, type BadgeString, Badges, type BadgesResolvable, Base, BaseManager, BitField, type BitFieldResolvable, Category, Channel, ChannelManager, ChannelPermissions, type ChannelPermissionsResolvable, type ChannelPermissionsString, type ChannelResolvable, ChannelTypes, type CreateChannelOptions, DEFAULT_CLIENT_OPTIONS, DEFAULT_PERMISSION_DM, DMChannel, type EditServerMemberOptions, type EditServerOptions, type Embed, type EmbedImage, type EmbedSpecial, type EmbedVideo, Emoji, Events, FullPermissions, GroupChannel, Invite, Mentions, type MessageEditOptions, MessageEmbed, MessageManager, type MessageOptions, type MessageQueryOptions, type MessageReply, type MessageResolvable, type MessageSearchOptions, MessageStruct, NotesChannel, type Overwrite, type PartialObject, Presence, Role, RoleManager, type RoleResolvable, SYSTEM_USER_ID, Server, ServerChannel, ServerChannelManager, type ServerChannelResolvable, ServerManager, ServerMember, ServerMemberManager, type ServerMemberResolvable, ServerPermissions, type ServerPermissionsResolvable, type ServerPermissionsString, type ServerResolvable, Status, TextChannel, UUID, User, UserManager, UserPermissions, type UserPermissionsResolvable, type UserPermissionsString, type UserResolvable, VoiceChannel, WSEvents, apiUrl, client };