revbot.js 0.1.9 → 0.1.10

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.
@@ -355,6 +358,7 @@ declare abstract class BaseClient extends EventEmitter {
355
358
 
356
359
  /**
357
360
  * Enum representing the client events that can be emitted.
361
+ * @private
358
362
  */
359
363
  declare enum Events {
360
364
  CHANNEL_CREATE = "channelCreate",
@@ -387,6 +391,7 @@ declare enum Events {
387
391
  }
388
392
  /**
389
393
  * Enum representing the WebSocket events used for communication.
394
+ * @private
390
395
  */
391
396
  declare enum WSEvents {
392
397
  AUTHENTICATE = "Authenticate",
@@ -1668,6 +1673,10 @@ declare class NotesChannel extends Channel implements TextBasedChannel {
1668
1673
  get user(): User;
1669
1674
  }
1670
1675
 
1676
+ /**
1677
+ * Represents a channel in the API.
1678
+ * @private
1679
+ */
1671
1680
  type APIServerChannel = Extract<Channel$1, {
1672
1681
  channel_type: "TextChannel" | "VoiceChannel";
1673
1682
  }>;
@@ -1690,6 +1699,8 @@ declare class ServerChannel extends Channel {
1690
1699
  description: string | null;
1691
1700
  /** The icon of the channel, or `null` if none is set. */
1692
1701
  icon: Attachment | null;
1702
+ /** Manages the messages in this Server channel. */
1703
+ messages: MessageManager;
1693
1704
  /** The permission overwrites for the channel. */
1694
1705
  overwrites: Map<string, Overwrite>;
1695
1706
  /** Whether the channel is marked as NSFW (Not Safe For Work). */
@@ -1728,6 +1739,18 @@ declare class ServerChannel extends Channel {
1728
1739
  * @returns {Server} The server instance.
1729
1740
  */
1730
1741
  get server(): Server;
1742
+ /**
1743
+ * Sends a message to this Server channel.
1744
+ *
1745
+ * @param {MessageOptions | string} options - The message content or options for the message.
1746
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1747
+ *
1748
+ * @example
1749
+ * ```typescript
1750
+ * await serverChannel.send("Hello, world!");
1751
+ * ```
1752
+ */
1753
+ send(options: MessageOptions | string): Promise<MessageStruct>;
1731
1754
  /**
1732
1755
  * Retrieves the category this channel belongs to, if any.
1733
1756
  *
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.
@@ -355,6 +358,7 @@ declare abstract class BaseClient extends EventEmitter {
355
358
 
356
359
  /**
357
360
  * Enum representing the client events that can be emitted.
361
+ * @private
358
362
  */
359
363
  declare enum Events {
360
364
  CHANNEL_CREATE = "channelCreate",
@@ -387,6 +391,7 @@ declare enum Events {
387
391
  }
388
392
  /**
389
393
  * Enum representing the WebSocket events used for communication.
394
+ * @private
390
395
  */
391
396
  declare enum WSEvents {
392
397
  AUTHENTICATE = "Authenticate",
@@ -1668,6 +1673,10 @@ declare class NotesChannel extends Channel implements TextBasedChannel {
1668
1673
  get user(): User;
1669
1674
  }
1670
1675
 
1676
+ /**
1677
+ * Represents a channel in the API.
1678
+ * @private
1679
+ */
1671
1680
  type APIServerChannel = Extract<Channel$1, {
1672
1681
  channel_type: "TextChannel" | "VoiceChannel";
1673
1682
  }>;
@@ -1690,6 +1699,8 @@ declare class ServerChannel extends Channel {
1690
1699
  description: string | null;
1691
1700
  /** The icon of the channel, or `null` if none is set. */
1692
1701
  icon: Attachment | null;
1702
+ /** Manages the messages in this Server channel. */
1703
+ messages: MessageManager;
1693
1704
  /** The permission overwrites for the channel. */
1694
1705
  overwrites: Map<string, Overwrite>;
1695
1706
  /** Whether the channel is marked as NSFW (Not Safe For Work). */
@@ -1728,6 +1739,18 @@ declare class ServerChannel extends Channel {
1728
1739
  * @returns {Server} The server instance.
1729
1740
  */
1730
1741
  get server(): Server;
1742
+ /**
1743
+ * Sends a message to this Server channel.
1744
+ *
1745
+ * @param {MessageOptions | string} options - The message content or options for the message.
1746
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1747
+ *
1748
+ * @example
1749
+ * ```typescript
1750
+ * await serverChannel.send("Hello, world!");
1751
+ * ```
1752
+ */
1753
+ send(options: MessageOptions | string): Promise<MessageStruct>;
1731
1754
  /**
1732
1755
  * Retrieves the category this channel belongs to, if any.
1733
1756
  *
package/dist/index.js CHANGED
@@ -2101,6 +2101,8 @@ var ServerChannel = class extends Channel {
2101
2101
  this.description = null;
2102
2102
  /** The icon of the channel, or `null` if none is set. */
2103
2103
  this.icon = null;
2104
+ /** Manages the messages in this Server channel. */
2105
+ this.messages = new MessageManager(this);
2104
2106
  /** The permission overwrites for the channel. */
2105
2107
  this.overwrites = /* @__PURE__ */ new Map();
2106
2108
  /** Whether the channel is marked as NSFW (Not Safe For Work). */
@@ -2171,6 +2173,20 @@ var ServerChannel = class extends Channel {
2171
2173
  get server() {
2172
2174
  return this.client.servers.cache.get(this.serverId);
2173
2175
  }
2176
+ /**
2177
+ * Sends a message to this Server channel.
2178
+ *
2179
+ * @param {MessageOptions | string} options - The message content or options for the message.
2180
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
2181
+ *
2182
+ * @example
2183
+ * ```typescript
2184
+ * await serverChannel.send("Hello, world!");
2185
+ * ```
2186
+ */
2187
+ send(options) {
2188
+ return this.messages.send(options);
2189
+ }
2174
2190
  /**
2175
2191
  * Retrieves the category this channel belongs to, if any.
2176
2192
  *
@@ -3292,7 +3308,7 @@ var import_node_events = require("events");
3292
3308
  var import_axios4 = require("axios");
3293
3309
 
3294
3310
  // package.json
3295
- var version = "0.1.8";
3311
+ var version = "0.1.10";
3296
3312
 
3297
3313
  // src/rest/restUtils/rateLimitQueue.ts
3298
3314
  var import_axios3 = __toESM(require("axios"));
@@ -4428,21 +4444,21 @@ var WebSocketClient = class {
4428
4444
  this.client.users._add(user);
4429
4445
  }
4430
4446
  }
4431
- for (const server of packet.servers) {
4432
- const s = this.client.servers._add(server);
4433
- if (this.client.options.fetchMembers) {
4434
- promises.push(s.members.fetch());
4435
- }
4436
- }
4437
- for (const channel of packet.channels) {
4438
- this.client.channels._add(channel);
4439
- }
4440
4447
  for (const member of packet.members) {
4441
4448
  (_a = this.client.servers.cache.get(member._id.server)) == null ? void 0 : _a.members._add(member);
4442
4449
  }
4443
4450
  for (const emoji of packet.emojis) {
4444
4451
  (_b = this.client.servers.cache.get(emoji.parent.id)) == null ? void 0 : _b.emojis.set(emoji._id, __spreadProps(__spreadValues({}, emoji), { _id: emoji._id }));
4445
4452
  }
4453
+ for (const channel of packet.channels) {
4454
+ this.client.channels._add(channel);
4455
+ }
4456
+ for (const server of packet.servers) {
4457
+ const s = this.client.servers._add(server);
4458
+ if (this.client.options.fetchMembers) {
4459
+ promises.push(s.members.fetch());
4460
+ }
4461
+ }
4446
4462
  this.setHeartbeatTimer(
4447
4463
  (_d = (_c = this.client.options.ws) == null ? void 0 : _c.heartbeatInterval) != null ? _d : 3e4
4448
4464
  );