@jubbio/core 1.0.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/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/Client.d.ts +147 -0
- package/dist/Client.js +471 -0
- package/dist/builders/ActionRowBuilder.d.ts +53 -0
- package/dist/builders/ActionRowBuilder.js +68 -0
- package/dist/builders/ButtonBuilder.d.ts +77 -0
- package/dist/builders/ButtonBuilder.js +96 -0
- package/dist/builders/EmbedBuilder.d.ts +157 -0
- package/dist/builders/EmbedBuilder.js +199 -0
- package/dist/builders/ModalBuilder.d.ts +122 -0
- package/dist/builders/ModalBuilder.js +162 -0
- package/dist/builders/SelectMenuBuilder.d.ts +123 -0
- package/dist/builders/SelectMenuBuilder.js +165 -0
- package/dist/builders/SlashCommandBuilder.d.ts +197 -0
- package/dist/builders/SlashCommandBuilder.js +324 -0
- package/dist/builders/index.d.ts +9 -0
- package/dist/builders/index.js +26 -0
- package/dist/enums.d.ts +196 -0
- package/dist/enums.js +216 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +128 -0
- package/dist/managers/BaseManager.d.ts +69 -0
- package/dist/managers/BaseManager.js +106 -0
- package/dist/managers/ChannelManager.d.ts +98 -0
- package/dist/managers/ChannelManager.js +209 -0
- package/dist/managers/GuildMemberManager.d.ts +74 -0
- package/dist/managers/GuildMemberManager.js +156 -0
- package/dist/managers/RoleManager.d.ts +84 -0
- package/dist/managers/RoleManager.js +207 -0
- package/dist/managers/index.d.ts +7 -0
- package/dist/managers/index.js +24 -0
- package/dist/rest/REST.d.ts +483 -0
- package/dist/rest/REST.js +805 -0
- package/dist/rest/index.d.ts +1 -0
- package/dist/rest/index.js +18 -0
- package/dist/sharding/ShardingManager.d.ts +179 -0
- package/dist/sharding/ShardingManager.js +375 -0
- package/dist/sharding/index.d.ts +4 -0
- package/dist/sharding/index.js +21 -0
- package/dist/structures/Channel.d.ts +120 -0
- package/dist/structures/Channel.js +224 -0
- package/dist/structures/Collection.d.ts +53 -0
- package/dist/structures/Collection.js +115 -0
- package/dist/structures/Guild.d.ts +59 -0
- package/dist/structures/Guild.js +90 -0
- package/dist/structures/GuildMember.d.ts +130 -0
- package/dist/structures/GuildMember.js +208 -0
- package/dist/structures/Interaction.d.ts +224 -0
- package/dist/structures/Interaction.js +404 -0
- package/dist/structures/Message.d.ts +93 -0
- package/dist/structures/Message.js +145 -0
- package/dist/structures/User.d.ts +37 -0
- package/dist/structures/User.js +65 -0
- package/dist/structures/index.d.ts +7 -0
- package/dist/structures/index.js +25 -0
- package/dist/structures.d.ts +1 -0
- package/dist/structures.js +19 -0
- package/dist/types.d.ts +255 -0
- package/dist/types.js +3 -0
- package/dist/utils/BitField.d.ts +66 -0
- package/dist/utils/BitField.js +138 -0
- package/dist/utils/Collection.d.ts +116 -0
- package/dist/utils/Collection.js +265 -0
- package/dist/utils/Collector.d.ts +152 -0
- package/dist/utils/Collector.js +314 -0
- package/dist/utils/DataResolver.d.ts +61 -0
- package/dist/utils/DataResolver.js +146 -0
- package/dist/utils/Formatters.d.ts +145 -0
- package/dist/utils/Formatters.js +213 -0
- package/dist/utils/IntentsBitField.d.ts +85 -0
- package/dist/utils/IntentsBitField.js +99 -0
- package/dist/utils/Partials.d.ts +105 -0
- package/dist/utils/Partials.js +149 -0
- package/dist/utils/PermissionsBitField.d.ts +118 -0
- package/dist/utils/PermissionsBitField.js +145 -0
- package/dist/utils/SnowflakeUtil.d.ts +63 -0
- package/dist/utils/SnowflakeUtil.js +93 -0
- package/dist/utils/Sweepers.d.ts +127 -0
- package/dist/utils/Sweepers.js +270 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +30 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jubbio Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://jubbio.com/logo.png" alt="Jubbio" width="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">@jubbio/core</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Core bot library for Jubbio platform</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@jubbio/core"><img src="https://img.shields.io/npm/v/@jubbio/core?color=blue" alt="npm"></a>
|
|
13
|
+
<a href="https://github.com/jubbio/jubbio.js/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License"></a>
|
|
14
|
+
<img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen" alt="Node.js">
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @jubbio/core
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Client, GatewayIntentBits } from '@jubbio/core';
|
|
29
|
+
|
|
30
|
+
const client = new Client({
|
|
31
|
+
intents: [
|
|
32
|
+
GatewayIntentBits.Guilds,
|
|
33
|
+
GatewayIntentBits.GuildMessages
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
client.on('ready', () => {
|
|
38
|
+
console.log(`✅ ${client.user?.username} is online!`);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
client.on('messageCreate', async (message) => {
|
|
42
|
+
if (message.content === '!ping') {
|
|
43
|
+
await message.reply('🏓 Pong!');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
client.on('interactionCreate', async (interaction) => {
|
|
48
|
+
if (!interaction.isCommand()) return;
|
|
49
|
+
|
|
50
|
+
if (interaction.commandName === 'hello') {
|
|
51
|
+
await interaction.reply('Hello! 👋');
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
client.login(process.env.BOT_TOKEN);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- 🔌 **WebSocket Gateway** - Real-time events with auto-reconnection
|
|
61
|
+
- 🌐 **REST API Client** - Full API coverage
|
|
62
|
+
- ⚡ **Slash Commands** - Easy interaction handling
|
|
63
|
+
- 📦 **Builders** - Embed, Button, SelectMenu, Modal builders
|
|
64
|
+
- 🔄 **Collectors** - Message and interaction collectors
|
|
65
|
+
- 🎯 **Sharding** - Multi-process support for large bots
|
|
66
|
+
- 📝 **TypeScript** - Full type definitions
|
|
67
|
+
|
|
68
|
+
## Client Options
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
const client = new Client({
|
|
72
|
+
intents: [...], // Required gateway intents
|
|
73
|
+
shards: [0, 1], // Optional: [shard_id, total_shards]
|
|
74
|
+
gatewayUrl: 'ws://...', // Optional: Custom gateway URL
|
|
75
|
+
apiUrl: 'http://...' // Optional: Custom API URL
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Gateway Intents
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
GatewayIntentBits.Guilds // Guild events
|
|
83
|
+
GatewayIntentBits.GuildMembers // Member events
|
|
84
|
+
GatewayIntentBits.GuildMessages // Message events
|
|
85
|
+
GatewayIntentBits.GuildVoiceStates // Voice state events
|
|
86
|
+
GatewayIntentBits.MessageContent // Message content access
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Events
|
|
90
|
+
|
|
91
|
+
| Event | Description |
|
|
92
|
+
|-------|-------------|
|
|
93
|
+
| `ready` | Bot is connected and ready |
|
|
94
|
+
| `messageCreate` | New message received |
|
|
95
|
+
| `interactionCreate` | Slash command or component interaction |
|
|
96
|
+
| `guildCreate` | Bot joined a guild |
|
|
97
|
+
| `guildDelete` | Bot left a guild |
|
|
98
|
+
| `voiceStateUpdate` | Voice state changed |
|
|
99
|
+
| `error` | Error occurred |
|
|
100
|
+
| `debug` | Debug information |
|
|
101
|
+
|
|
102
|
+
## Builders
|
|
103
|
+
|
|
104
|
+
### EmbedBuilder
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { EmbedBuilder, Colors } from '@jubbio/core';
|
|
108
|
+
|
|
109
|
+
const embed = new EmbedBuilder()
|
|
110
|
+
.setTitle('Hello!')
|
|
111
|
+
.setDescription('This is an embed')
|
|
112
|
+
.setColor(Colors.Blue)
|
|
113
|
+
.addFields(
|
|
114
|
+
{ name: 'Field 1', value: 'Value 1', inline: true },
|
|
115
|
+
{ name: 'Field 2', value: 'Value 2', inline: true }
|
|
116
|
+
)
|
|
117
|
+
.setFooter({ text: 'Footer text' })
|
|
118
|
+
.setTimestamp();
|
|
119
|
+
|
|
120
|
+
await message.reply({ embeds: [embed] });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### ButtonBuilder
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
import { ButtonBuilder, ButtonStyle, ActionRowBuilder } from '@jubbio/core';
|
|
127
|
+
|
|
128
|
+
const button = new ButtonBuilder()
|
|
129
|
+
.setCustomId('my-button')
|
|
130
|
+
.setLabel('Click me!')
|
|
131
|
+
.setStyle(ButtonStyle.Primary);
|
|
132
|
+
|
|
133
|
+
const row = new ActionRowBuilder().addComponents(button);
|
|
134
|
+
|
|
135
|
+
await interaction.reply({ components: [row] });
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### SlashCommandBuilder
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { SlashCommandBuilder } from '@jubbio/core';
|
|
142
|
+
|
|
143
|
+
const command = new SlashCommandBuilder()
|
|
144
|
+
.setName('greet')
|
|
145
|
+
.setDescription('Greet a user')
|
|
146
|
+
.addUserOption(option =>
|
|
147
|
+
option.setName('user')
|
|
148
|
+
.setDescription('User to greet')
|
|
149
|
+
.setRequired(true)
|
|
150
|
+
);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Voice Support
|
|
154
|
+
|
|
155
|
+
Use with `@jubbio/voice` for voice channel support:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { Client, GatewayIntentBits } from '@jubbio/core';
|
|
159
|
+
import { joinVoiceChannel, createAudioPlayer } from '@jubbio/voice';
|
|
160
|
+
|
|
161
|
+
// See @jubbio/voice documentation for full voice support
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT © [Jubbio Team](https://jubbio.com)
|
package/dist/Client.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { ClientOptions } from './types';
|
|
3
|
+
import { GatewayIntentBits } from './enums';
|
|
4
|
+
import { Collection } from './structures/Collection';
|
|
5
|
+
import { User } from './structures/User';
|
|
6
|
+
import { Guild } from './structures/Guild';
|
|
7
|
+
import { BaseChannel } from './structures/Channel';
|
|
8
|
+
import { REST } from './rest/REST';
|
|
9
|
+
/**
|
|
10
|
+
* Voice adapter creator type for @jubbio/voice compatibility
|
|
11
|
+
*/
|
|
12
|
+
type VoiceAdapterCreator = (methods: {
|
|
13
|
+
onVoiceServerUpdate(data: any): void;
|
|
14
|
+
onVoiceStateUpdate(data: any): void;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
}) => {
|
|
17
|
+
sendPayload(payload: any): boolean;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Main client class
|
|
22
|
+
*/
|
|
23
|
+
export declare class Client extends EventEmitter {
|
|
24
|
+
/** Client options */
|
|
25
|
+
readonly options: ClientOptions;
|
|
26
|
+
/** REST API client */
|
|
27
|
+
readonly rest: REST;
|
|
28
|
+
/** The bot user */
|
|
29
|
+
user: User | null;
|
|
30
|
+
/** Application ID */
|
|
31
|
+
applicationId: string | null;
|
|
32
|
+
/** Cached guilds */
|
|
33
|
+
guilds: Collection<string, Guild>;
|
|
34
|
+
/** Cached channels */
|
|
35
|
+
channels: Collection<string, BaseChannel>;
|
|
36
|
+
/** Cached users */
|
|
37
|
+
users: Collection<string, User>;
|
|
38
|
+
/** Voice adapter management */
|
|
39
|
+
voice: {
|
|
40
|
+
adapters: Map<string, VoiceAdapterCreator>;
|
|
41
|
+
};
|
|
42
|
+
/** WebSocket connection */
|
|
43
|
+
private ws;
|
|
44
|
+
/** Bot token */
|
|
45
|
+
private token;
|
|
46
|
+
/** Session ID */
|
|
47
|
+
private sessionId;
|
|
48
|
+
/** Sequence number */
|
|
49
|
+
private sequence;
|
|
50
|
+
/** Heartbeat interval */
|
|
51
|
+
private heartbeatInterval;
|
|
52
|
+
/** Gateway URL */
|
|
53
|
+
private gatewayUrl;
|
|
54
|
+
/** Voice state update handlers (for voice adapters) */
|
|
55
|
+
private voiceStateHandlers;
|
|
56
|
+
private voiceServerHandlers;
|
|
57
|
+
constructor(options: ClientOptions);
|
|
58
|
+
/**
|
|
59
|
+
* Calculate intents value
|
|
60
|
+
*/
|
|
61
|
+
private getIntentsValue;
|
|
62
|
+
/**
|
|
63
|
+
* Login to the gateway
|
|
64
|
+
*/
|
|
65
|
+
login(token: string): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Connect to the gateway
|
|
68
|
+
*/
|
|
69
|
+
private connect;
|
|
70
|
+
/**
|
|
71
|
+
* Handle incoming gateway message
|
|
72
|
+
*/
|
|
73
|
+
private handleMessage;
|
|
74
|
+
/**
|
|
75
|
+
* Handle gateway payload
|
|
76
|
+
*/
|
|
77
|
+
private handlePayload;
|
|
78
|
+
/**
|
|
79
|
+
* Handle Hello payload
|
|
80
|
+
*/
|
|
81
|
+
private handleHello;
|
|
82
|
+
/**
|
|
83
|
+
* Handle Dispatch events
|
|
84
|
+
*/
|
|
85
|
+
private handleDispatch;
|
|
86
|
+
/**
|
|
87
|
+
* Handle Ready event
|
|
88
|
+
*/
|
|
89
|
+
private handleReady;
|
|
90
|
+
/**
|
|
91
|
+
* Setup voice adapters for all guilds
|
|
92
|
+
*/
|
|
93
|
+
private setupVoiceAdapters;
|
|
94
|
+
/**
|
|
95
|
+
* Create a voice adapter for a guild
|
|
96
|
+
*/
|
|
97
|
+
private createVoiceAdapter;
|
|
98
|
+
/**
|
|
99
|
+
* Handle Guild Create event
|
|
100
|
+
*/
|
|
101
|
+
private handleGuildCreate;
|
|
102
|
+
/**
|
|
103
|
+
* Handle Guild Update event
|
|
104
|
+
*/
|
|
105
|
+
private handleGuildUpdate;
|
|
106
|
+
/**
|
|
107
|
+
* Handle Guild Delete event
|
|
108
|
+
*/
|
|
109
|
+
private handleGuildDelete;
|
|
110
|
+
/**
|
|
111
|
+
* Handle Message Create event
|
|
112
|
+
*/
|
|
113
|
+
private handleMessageCreate;
|
|
114
|
+
/**
|
|
115
|
+
* Handle Interaction Create event
|
|
116
|
+
*/
|
|
117
|
+
private handleInteractionCreate;
|
|
118
|
+
/**
|
|
119
|
+
* Handle Voice State Update event
|
|
120
|
+
*/
|
|
121
|
+
private handleVoiceStateUpdate;
|
|
122
|
+
/**
|
|
123
|
+
* Handle Voice Server Update event
|
|
124
|
+
*/
|
|
125
|
+
private handleVoiceServerUpdate;
|
|
126
|
+
/**
|
|
127
|
+
* Send Identify payload
|
|
128
|
+
*/
|
|
129
|
+
private identify;
|
|
130
|
+
/**
|
|
131
|
+
* Start heartbeat
|
|
132
|
+
*/
|
|
133
|
+
private startHeartbeat;
|
|
134
|
+
/**
|
|
135
|
+
* Send payload to gateway
|
|
136
|
+
*/
|
|
137
|
+
private send;
|
|
138
|
+
/**
|
|
139
|
+
* Cleanup on disconnect
|
|
140
|
+
*/
|
|
141
|
+
private cleanup;
|
|
142
|
+
/**
|
|
143
|
+
* Destroy the client
|
|
144
|
+
*/
|
|
145
|
+
destroy(): void;
|
|
146
|
+
}
|
|
147
|
+
export { GatewayIntentBits };
|