revbot.js 0.1.8 → 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.
@@ -194,7 +197,6 @@ declare class CDNClient {
194
197
  * POST request.
195
198
  * @param url The URL for the request.
196
199
  * @param data The request body.
197
- * @param query Query parameters (if applicable).
198
200
  * @returns The API response.
199
201
  */
200
202
  post<T>(url: string, data: FormData): Promise<T>;
@@ -356,6 +358,7 @@ declare abstract class BaseClient extends EventEmitter {
356
358
 
357
359
  /**
358
360
  * Enum representing the client events that can be emitted.
361
+ * @private
359
362
  */
360
363
  declare enum Events {
361
364
  CHANNEL_CREATE = "channelCreate",
@@ -388,6 +391,7 @@ declare enum Events {
388
391
  }
389
392
  /**
390
393
  * Enum representing the WebSocket events used for communication.
394
+ * @private
391
395
  */
392
396
  declare enum WSEvents {
393
397
  AUTHENTICATE = "Authenticate",
@@ -1669,9 +1673,14 @@ declare class NotesChannel extends Channel implements TextBasedChannel {
1669
1673
  get user(): User;
1670
1674
  }
1671
1675
 
1672
- type APIServerChannel$1 = Extract<Channel$1, {
1676
+ /**
1677
+ * Represents a channel in the API.
1678
+ * @private
1679
+ */
1680
+ type APIServerChannel = Extract<Channel$1, {
1673
1681
  channel_type: "TextChannel" | "VoiceChannel";
1674
1682
  }>;
1683
+
1675
1684
  interface Overwrite {
1676
1685
  allow: FullPermissions;
1677
1686
  deny: FullPermissions;
@@ -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). */
@@ -1700,7 +1711,7 @@ declare class ServerChannel extends Channel {
1700
1711
  * @param {client} client - The client instance.
1701
1712
  * @param {APIServerChannel} data - The raw data for the server channel from the API.
1702
1713
  */
1703
- constructor(client: client, data: APIServerChannel$1);
1714
+ constructor(client: client, data: APIServerChannel);
1704
1715
  /**
1705
1716
  * Updates the server channel instance with new data from the API.
1706
1717
  *
@@ -1709,7 +1720,7 @@ declare class ServerChannel extends Channel {
1709
1720
  * @returns {this} The updated server channel instance.
1710
1721
  * @protected
1711
1722
  */
1712
- protected _patch(data: APIServerChannel$1, clear?: FieldsChannel[]): this;
1723
+ protected _patch(data: APIServerChannel, clear?: FieldsChannel[]): this;
1713
1724
  /**
1714
1725
  * Creates an invite for the server channel.
1715
1726
  *
@@ -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
  *
@@ -2033,6 +2056,7 @@ declare class Emoji extends Base {
2033
2056
 
2034
2057
  type UserResolvable = User | User$1 | MessageStruct | string;
2035
2058
  declare class UserManager extends BaseManager<User, User$1> {
2059
+ /** @private */
2036
2060
  holds: typeof User;
2037
2061
  /**
2038
2062
  *
@@ -2081,10 +2105,12 @@ declare class ClientUser extends User {
2081
2105
  * ```
2082
2106
  */
2083
2107
  setUsername(username: string, password?: string): Promise<void>;
2108
+ setStatus(text?: string | null): Promise<void>;
2109
+ setStatus(presence?: Status): Promise<void>;
2084
2110
  /**
2085
2111
  * Updates the status of the client user.
2086
2112
  *
2087
- * @param {string | null} text - The status text to set, or `null` to clear the status.
2113
+ * @param {string | null} [text] - The status text to set, or `null` to clear the status.
2088
2114
  * @param {Status} [presence] - The presence status (e.g., online, idle, etc.).
2089
2115
  * @returns {Promise<void>} A promise that resolves when the status has been successfully updated.
2090
2116
  *
@@ -2093,14 +2119,13 @@ declare class ClientUser extends User {
2093
2119
  * await clientUser.setStatus("Available", "Online");
2094
2120
  * ```
2095
2121
  */
2096
- setStatus(text?: string | null): Promise<void>;
2097
- setStatus(presence?: Status): Promise<void>;
2098
2122
  setStatus(text?: string | null, presence?: keyof typeof Status): Promise<void>;
2099
2123
  }
2100
2124
 
2101
2125
  /**
2102
2126
  * Represents the base class for all event handlers.
2103
2127
  * All event handlers must extend this class and implement the `handle` method.
2128
+ * @private
2104
2129
  */
2105
2130
  declare abstract class Event {
2106
2131
  protected readonly client: client;
@@ -2122,6 +2147,8 @@ declare abstract class Event {
2122
2147
 
2123
2148
  /**
2124
2149
  * Manages the registration and retrieval of events for the client.
2150
+ * @private
2151
+ * @extends Event
2125
2152
  */
2126
2153
  declare class EventManager {
2127
2154
  #private;
@@ -2332,14 +2359,18 @@ declare abstract class BaseManager<Holds extends {
2332
2359
  readonly cache: Map<string, Holds>;
2333
2360
  /** Instance level max size (can be changed per manager instance). */
2334
2361
  protected maxSize: number;
2362
+ /** @private */
2335
2363
  Holds: any;
2336
2364
  constructor(client: client, maxSize?: number);
2337
2365
  /**
2338
2366
  * Adds a raw object to the cache, constructing the holdable class.
2339
2367
  * Automatically evicts oldest entries if the max size is exceeded.
2368
+ * @private
2340
2369
  */
2341
2370
  _add(raw: R): Holds;
2342
- /** Remove an entry by id. */
2371
+ /** Remove an entry by id.
2372
+ * @private
2373
+ */
2343
2374
  _remove(id: string): void;
2344
2375
  /** Adjust the maximum size for this manager at runtime. */
2345
2376
  setMaxSize(size: number): void;
@@ -2355,7 +2386,9 @@ declare abstract class BaseManager<Holds extends {
2355
2386
 
2356
2387
  type ChannelResolvable = Channel | Channel$1 | string;
2357
2388
  declare class ChannelManager extends BaseManager<Channel, Channel$1> {
2389
+ /** @private */
2358
2390
  holds: null;
2391
+ /** @private */
2359
2392
  _add(data: Channel$1): Channel;
2360
2393
  _remove(id: string): void;
2361
2394
  /**
@@ -2395,7 +2428,9 @@ interface EditServerOptions {
2395
2428
  description?: string;
2396
2429
  }
2397
2430
  declare class ServerManager extends BaseManager<Server, Server$1> {
2431
+ /** @private */
2398
2432
  readonly holds: typeof Server;
2433
+ /** @private */
2399
2434
  _remove(id: string): void;
2400
2435
  /**
2401
2436
  * edits a server
@@ -2449,6 +2484,7 @@ interface MessageQueryOptions {
2449
2484
  }
2450
2485
  declare class MessageManager extends BaseManager<MessageStruct, Message> {
2451
2486
  protected readonly channel: Channel;
2487
+ /** @private */
2452
2488
  holds: typeof MessageStruct;
2453
2489
  constructor(channel: Channel, maxSize?: number);
2454
2490
  /**
@@ -2540,8 +2576,10 @@ declare class RoleManager extends BaseManager<Role, Role$1 & {
2540
2576
  id: string;
2541
2577
  }> {
2542
2578
  protected readonly server: Server;
2579
+ /** @private */
2543
2580
  holds: typeof Role;
2544
2581
  constructor(server: Server);
2582
+ /** @private */
2545
2583
  _add(data: Role$1 & {
2546
2584
  id: string;
2547
2585
  }): Role;
@@ -2573,9 +2611,6 @@ declare class RoleManager extends BaseManager<Role, Role$1 & {
2573
2611
  edit(role: RoleResolvable, data: editableRole): Promise<Role>;
2574
2612
  }
2575
2613
 
2576
- type APIServerChannel = Extract<Channel$1, {
2577
- channel_type: "TextChannel" | "VoiceChannel";
2578
- }>;
2579
2614
  type ServerChannelResolvable = ServerChannel | APIServerChannel | string;
2580
2615
  interface CreateChannelOptions {
2581
2616
  name: string;
@@ -2584,15 +2619,18 @@ interface CreateChannelOptions {
2584
2619
  }
2585
2620
  declare class ServerChannelManager extends BaseManager<ServerChannel> {
2586
2621
  protected readonly server: Server;
2622
+ /** @private */
2587
2623
  holds: typeof ServerChannel;
2588
2624
  constructor(server: Server);
2625
+ /** @private */
2589
2626
  _add(data: APIServerChannel): ServerChannel;
2590
2627
  /**
2591
- * creates a new channel in the server
2592
- * @param name The name of the channel to create
2593
- * @param type The type of the channel to create. Can be "Text" or "Voice". Defaults to "Text".
2594
- * @param description The description of the channel to create. Only used for voice channels.
2595
- * @returns A promise that resolves to the created channel
2628
+ * Creates a new channel in the server.
2629
+ * @param options - Options for creating the channel.
2630
+ * @param options.name - The name of the channel to create.
2631
+ * @param [options.type="Text"] - The type of the channel to create. Can be "Text" or "Voice". Defaults to "Text".
2632
+ * @param [options.description] - The description of the channel to create. Only used for voice channels.
2633
+ * @returns A promise that resolves to the created channel.
2596
2634
  */
2597
2635
  create({ name, type, description, }: CreateChannelOptions): Promise<ServerChannel>;
2598
2636
  /**
@@ -2615,6 +2653,7 @@ interface EditServerMemberOptions {
2615
2653
  }
2616
2654
  declare class ServerMemberManager extends BaseManager<ServerMember, Member> {
2617
2655
  protected readonly server: Server;
2656
+ /** @private */
2618
2657
  holds: typeof ServerMember;
2619
2658
  constructor(server: Server);
2620
2659
  /**
@@ -2661,4 +2700,4 @@ declare class ServerMemberManager extends BaseManager<ServerMember, Member> {
2661
2700
  resolveId(member: ServerMemberResolvable): string | null;
2662
2701
  }
2663
2702
 
2664
- 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, 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 };
2703
+ 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 };