disgroove 1.0.8 → 1.1.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 +43 -10
- package/dist/{class/Client.d.ts → Client.d.ts} +41 -6
- package/dist/Client.js +817 -0
- package/dist/Client.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rest/REST.d.ts +34 -3
- package/dist/rest/REST.js +27 -53
- package/dist/rest/REST.js.map +1 -1
- package/dist/rest/RequestsManager.d.ts +26 -0
- package/dist/rest/RequestsManager.js +102 -0
- package/dist/rest/RequestsManager.js.map +1 -0
- package/dist/rest/index.d.ts +1 -0
- package/dist/rest/index.js +1 -0
- package/dist/rest/index.js.map +1 -1
- package/dist/structures/Application.d.ts +16 -1
- package/dist/structures/Application.js +30 -30
- package/dist/structures/Application.js.map +1 -1
- package/dist/structures/ApplicationCommand.d.ts +5 -1
- package/dist/structures/ApplicationCommand.js +10 -10
- package/dist/structures/ApplicationCommand.js.map +1 -1
- package/dist/structures/AutoModerationRule.d.ts +3 -1
- package/dist/structures/AutoModerationRule.js +4 -4
- package/dist/structures/AutoModerationRule.js.map +1 -1
- package/dist/structures/Base.d.ts +1 -1
- package/dist/structures/Channel.d.ts +41 -1
- package/dist/structures/Channel.js +82 -82
- package/dist/structures/Channel.js.map +1 -1
- package/dist/structures/Guild.d.ts +79 -1
- package/dist/structures/Guild.js +164 -174
- package/dist/structures/Guild.js.map +1 -1
- package/dist/structures/GuildMember.d.ts +7 -1
- package/dist/structures/GuildMember.js +12 -12
- package/dist/structures/GuildMember.js.map +1 -1
- package/dist/structures/GuildScheduledEvent.d.ts +4 -1
- package/dist/structures/GuildScheduledEvent.js +6 -6
- package/dist/structures/GuildScheduledEvent.js.map +1 -1
- package/dist/structures/GuildTemplate.d.ts +4 -1
- package/dist/structures/GuildTemplate.js +6 -6
- package/dist/structures/GuildTemplate.js.map +1 -1
- package/dist/structures/Integration.d.ts +2 -1
- package/dist/structures/Integration.js +2 -2
- package/dist/structures/Integration.js.map +1 -1
- package/dist/structures/Interaction.d.ts +9 -1
- package/dist/structures/Interaction.js +22 -22
- package/dist/structures/Interaction.js.map +1 -1
- package/dist/structures/Invite.d.ts +2 -1
- package/dist/structures/Invite.js +2 -2
- package/dist/structures/Invite.js.map +1 -1
- package/dist/structures/Message.d.ts +11 -1
- package/dist/structures/Message.js +21 -21
- package/dist/structures/Message.js.map +1 -1
- package/dist/structures/Role.d.ts +2 -1
- package/dist/structures/Role.js +2 -2
- package/dist/structures/Role.js.map +1 -1
- package/dist/structures/StageInstance.d.ts +3 -1
- package/dist/structures/StageInstance.js +4 -4
- package/dist/structures/StageInstance.js.map +1 -1
- package/dist/structures/User.d.ts +9 -1
- package/dist/structures/User.js +16 -18
- package/dist/structures/User.js.map +1 -1
- package/dist/structures/Webhook.d.ts +11 -1
- package/dist/structures/Webhook.js +22 -22
- package/dist/structures/Webhook.js.map +1 -1
- package/dist/types/application-command.d.ts +5 -0
- package/dist/types/application-role-connection-metadata.d.ts +1 -0
- package/dist/types/application.d.ts +2 -0
- package/dist/types/audit-log.d.ts +4 -0
- package/dist/types/auto-moderation.d.ts +6 -0
- package/dist/types/channel.d.ts +23 -0
- package/dist/types/emoji.d.ts +1 -0
- package/dist/types/gateway-events.d.ts +38 -0
- package/dist/types/guild-scheduled-event.d.ts +3 -0
- package/dist/types/guild-template.d.ts +1 -0
- package/dist/types/guild.d.ts +14 -0
- package/dist/types/interaction.d.ts +7 -0
- package/dist/types/invite.d.ts +3 -0
- package/dist/types/message-components.d.ts +4 -0
- package/dist/types/role.d.ts +2 -0
- package/dist/types/stage-instance.d.ts +1 -0
- package/dist/types/sticker.d.ts +3 -0
- package/dist/types/team.d.ts +2 -0
- package/dist/types/user.d.ts +3 -0
- package/dist/types/voice.d.ts +2 -0
- package/dist/types/webhook.d.ts +1 -0
- package/dist/utils/constants.d.ts +71 -0
- package/dist/utils/constants.js +71 -71
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/jsoners.d.ts +1 -1
- package/dist/utils/rawers.d.ts +46 -1
- package/dist/utils/rawers.js +4 -4
- package/dist/utils/rawers.js.map +1 -1
- package/package.json +28 -27
- package/dist/class/Client.js +0 -724
- package/dist/class/Client.js.map +0 -1
- package/dist/class/index.d.ts +0 -1
- package/dist/class/index.js +0 -18
- package/dist/class/index.js.map +0 -1
- package/dist/structures/AuditLogEntry.d.ts +0 -15
- package/dist/structures/AuditLogEntry.js +0 -52
- package/dist/structures/AuditLogEntry.js.map +0 -1
- package/dist/types/oauth2.d.ts +0 -14
- package/dist/types/oauth2.js +0 -3
- package/dist/types/oauth2.js.map +0 -1
package/README.md
CHANGED
|
@@ -27,26 +27,59 @@ const client = new Client("token", {
|
|
|
27
27
|
### Example
|
|
28
28
|
|
|
29
29
|
```js
|
|
30
|
-
const {
|
|
30
|
+
const {
|
|
31
|
+
Client,
|
|
32
|
+
GatewayIntents,
|
|
33
|
+
GatewayEvents,
|
|
34
|
+
ActivityType,
|
|
35
|
+
StatusTypes,
|
|
36
|
+
InteractionType,
|
|
37
|
+
InteractionCallbackType,
|
|
38
|
+
MessageFlags,
|
|
39
|
+
} = require("disgroove");
|
|
31
40
|
const client = new Client("token", {
|
|
32
41
|
intents: GatewayIntents.All,
|
|
33
42
|
});
|
|
34
43
|
|
|
35
44
|
client.on(GatewayEvents.Ready, async () => {
|
|
36
|
-
const user = await client.getUser();
|
|
45
|
+
const user = await client.getUser(); // Get the bot user
|
|
37
46
|
|
|
38
|
-
console.log(`${user.username} is
|
|
47
|
+
console.log(`${user.username} is now online!`); // Print "Username is now online!" when the bot connects to the gateway
|
|
48
|
+
|
|
49
|
+
const application = await client.getApplication(); // Get the bot application
|
|
50
|
+
|
|
51
|
+
await application.createGlobalApplicationCommand({
|
|
52
|
+
name: "ping",
|
|
53
|
+
description: "Reply with Pong! �",
|
|
54
|
+
}); // Create a global application command named "ping"
|
|
55
|
+
|
|
56
|
+
client.updatePresence({
|
|
57
|
+
activities: [
|
|
58
|
+
{
|
|
59
|
+
name: "/ping",
|
|
60
|
+
type: ActivityType.Watching,
|
|
61
|
+
createdAt: Date.now(),
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
status: StatusTypes.Online,
|
|
65
|
+
afk: false,
|
|
66
|
+
}); // Update the bot presence to "Watching /ping"
|
|
39
67
|
});
|
|
40
68
|
|
|
41
|
-
client.on(GatewayEvents.
|
|
42
|
-
if (
|
|
43
|
-
const channel = await client.getChannel(message.channelId);
|
|
69
|
+
client.on(GatewayEvents.InteractionCreate, async (interaction) => {
|
|
70
|
+
if (interaction.type !== InteractionType.ApplicationCommand) return; // Check if the interaction is an application command
|
|
44
71
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
72
|
+
if (interaction.data.name === "ping") {
|
|
73
|
+
// Check if the application command name is equals to "ping"
|
|
74
|
+
await interaction.createResponse({
|
|
75
|
+
type: InteractionCallbackType.ChannelMessageWithSource,
|
|
76
|
+
data: {
|
|
77
|
+
content: "Pong! �",
|
|
78
|
+
flags: MessageFlags.Ephemeral,
|
|
79
|
+
},
|
|
80
|
+
}); // Reply with an ephemeral message "Pong! �"
|
|
48
81
|
}
|
|
49
82
|
});
|
|
50
83
|
|
|
51
|
-
client.connect();
|
|
84
|
+
client.connect(); // Connect the bot to the gateway
|
|
52
85
|
```
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import WebSocket from "ws";
|
|
3
|
-
import { type DefaultMessageNotificationLevel, type ExplicitContentFilterLevel, GatewayEvents, GatewayIntents, type GuildFeatures, type OAuth2Scopes, type PrivacyLevel,
|
|
4
|
-
import { REST } from "
|
|
5
|
-
import { Application, AutoModerationRule, Channel, Guild, GuildMember, GuildScheduledEvent, Integration, Interaction, Invite, Message, StageInstance, User } from "
|
|
6
|
-
import type { JSONActivity, JSONAuditLogEntry, JSONAutoModerationActionExectionEventFields, JSONAutoModerationRule, JSONChannel, JSONChannelPinsUpdateEventFields, JSONGuildApplicationCommandPermissions, JSONGuildBanAddEventFields, JSONGuildBanRemoveEventFields, JSONGuildDeleteEventFields, JSONGuildEmojisUpdateEventFields, JSONGuildIntegrationsUpdateEventFields, JSONGuildMemberRemoveEventFields, JSONGuildMemberUpdateEventFields, JSONGuildMembersChunkEventFields, JSONGuildRoleCreateEventFields, JSONGuildRoleDeleteEventFields, JSONGuildRoleUpdateEventFields, JSONGuildScheduledEvent, JSONGuildScheduledEventUserAddEventFields, JSONGuildScheduledEventUserRemoveEventFields, JSONGuildStickersUpdateEventFields, JSONIntegrationDeleteEventFields, JSONInvite, JSONInviteCreateEventFields, JSONInviteDeleteEventFields, JSONMessageDeleteBulkEventFields, JSONMessageDeleteEventFields, JSONMessageReactionAddEventFields, JSONMessageReactionRemoveAllEventFields, JSONMessageReactionRemoveEmojiEventFields, JSONMessageReactionRemoveEventFields, JSONPresenceUpdateEventFields, JSONRole, JSONStageInstance, JSONStickerPack, JSONThreadListSyncEventFields, JSONThreadMember, JSONThreadMembersUpdateEventFields, JSONTypingStartEventFields, JSONVoiceRegion, JSONVoiceServerUpdateEventFields, JSONVoiceState, JSONWebhooksUpdateEventFields } from "
|
|
3
|
+
import { type DefaultMessageNotificationLevel, type ExplicitContentFilterLevel, GatewayEvents, GatewayIntents, type GuildFeatures, type OAuth2Scopes, type PrivacyLevel, StatusTypes, type SystemChannelFlags, type VerificationLevel } from "./utils";
|
|
4
|
+
import { REST } from "./rest";
|
|
5
|
+
import { Application, AutoModerationRule, Channel, Guild, GuildMember, GuildScheduledEvent, Integration, Interaction, Invite, Message, StageInstance, User } from "./structures";
|
|
6
|
+
import type { JSONActivity, JSONAuditLogEntry, JSONAutoModerationActionExectionEventFields, JSONAutoModerationRule, JSONChannel, JSONChannelPinsUpdateEventFields, JSONGuildApplicationCommandPermissions, JSONGuildBanAddEventFields, JSONGuildBanRemoveEventFields, JSONGuildDeleteEventFields, JSONGuildEmojisUpdateEventFields, JSONGuildIntegrationsUpdateEventFields, JSONGuildMemberRemoveEventFields, JSONGuildMemberUpdateEventFields, JSONGuildMembersChunkEventFields, JSONGuildRoleCreateEventFields, JSONGuildRoleDeleteEventFields, JSONGuildRoleUpdateEventFields, JSONGuildScheduledEvent, JSONGuildScheduledEventUserAddEventFields, JSONGuildScheduledEventUserRemoveEventFields, JSONGuildStickersUpdateEventFields, JSONIntegrationDeleteEventFields, JSONInvite, JSONInviteCreateEventFields, JSONInviteDeleteEventFields, JSONMessageDeleteBulkEventFields, JSONMessageDeleteEventFields, JSONMessageReactionAddEventFields, JSONMessageReactionRemoveAllEventFields, JSONMessageReactionRemoveEmojiEventFields, JSONMessageReactionRemoveEventFields, JSONPresenceUpdateEventFields, JSONRole, JSONStageInstance, JSONStickerPack, JSONThreadListSyncEventFields, JSONThreadMember, JSONThreadMembersUpdateEventFields, JSONTypingStartEventFields, JSONVoiceRegion, JSONVoiceServerUpdateEventFields, JSONVoiceState, JSONWebhooksUpdateEventFields } from "./types";
|
|
7
7
|
import EventEmitter from "node:events";
|
|
8
8
|
export interface ClientOptions {
|
|
9
9
|
intents?: GatewayIntents | number;
|
|
10
|
+
auth?: "Bot" | "Bearer";
|
|
11
|
+
presence?: {
|
|
12
|
+
activities: Array<JSONActivity>;
|
|
13
|
+
status: StatusTypes;
|
|
14
|
+
afk: boolean;
|
|
15
|
+
};
|
|
10
16
|
}
|
|
11
17
|
export declare interface Client extends EventEmitter {
|
|
12
18
|
on(event: GatewayEvents.Hello, listener: (listener: {
|
|
@@ -78,14 +84,23 @@ export declare interface Client extends EventEmitter {
|
|
|
78
84
|
on(event: GatewayEvents.StageInstanceDelete, listener: (listener: JSONStageInstance) => void): this;
|
|
79
85
|
}
|
|
80
86
|
export declare class Client extends EventEmitter {
|
|
81
|
-
private heartbeatInterval
|
|
87
|
+
private heartbeatInterval;
|
|
82
88
|
token: string;
|
|
83
89
|
intents: GatewayIntents | number;
|
|
90
|
+
auth: "Bot" | "Bearer";
|
|
91
|
+
presence?: {
|
|
92
|
+
activities: Array<JSONActivity>;
|
|
93
|
+
status: StatusTypes;
|
|
94
|
+
afk: boolean;
|
|
95
|
+
};
|
|
84
96
|
rest: REST;
|
|
85
97
|
ws: WebSocket;
|
|
86
98
|
constructor(token: string, options?: ClientOptions);
|
|
99
|
+
/** https://discord.com/developers/docs/resources/application#get-current-application */
|
|
87
100
|
getApplication(): Promise<Application>;
|
|
101
|
+
/** https://discord.com/developers/docs/resources/channel#get-channel */
|
|
88
102
|
getChannel(channelId: string): Promise<Channel>;
|
|
103
|
+
/** https://discord.com/developers/docs/resources/guild#create-guild */
|
|
89
104
|
createGuild(options: {
|
|
90
105
|
name: string;
|
|
91
106
|
region?: string | null;
|
|
@@ -100,30 +115,39 @@ export declare class Client extends EventEmitter {
|
|
|
100
115
|
systemChannelId?: string;
|
|
101
116
|
systemChannelFlags?: SystemChannelFlags;
|
|
102
117
|
}): Promise<Guild>;
|
|
118
|
+
/** https://discord.com/developers/docs/resources/guild#get-guild */
|
|
103
119
|
getGuild(guildId: string, options?: {
|
|
104
120
|
withCounts?: boolean;
|
|
105
121
|
}): Promise<Guild>;
|
|
122
|
+
/** https://discord.com/developers/docs/resources/guild-template#create-guild-from-guild-template */
|
|
106
123
|
createGuildFromTemplate(code: string, options: {
|
|
107
124
|
name: string;
|
|
108
125
|
icon?: string;
|
|
109
126
|
}): Promise<Guild>;
|
|
127
|
+
/** https://discord.com/developers/docs/resources/invite#get-invite */
|
|
110
128
|
getInvite(code: string, options?: {
|
|
111
129
|
withCounts?: boolean;
|
|
112
130
|
withExpiration?: boolean;
|
|
113
131
|
guildScheduledEventId?: string;
|
|
114
132
|
}): Promise<Invite>;
|
|
133
|
+
/** https://discord.com/developers/docs/resources/invite#delete-invite */
|
|
115
134
|
deleteInvite(code: string, reason?: string): Promise<JSONInvite>;
|
|
135
|
+
/** https://discord.com/developers/docs/resources/stage-instance#create-stage-instance */
|
|
116
136
|
createStageInstance(options: {
|
|
117
137
|
channelId: string;
|
|
118
138
|
topic: string;
|
|
119
139
|
privacyLevel?: PrivacyLevel;
|
|
120
140
|
sendStartNotifications?: boolean;
|
|
121
141
|
}, reason?: string): Promise<StageInstance>;
|
|
142
|
+
/** https://discord.com/developers/docs/resources/stage-instance#get-stage-instance */
|
|
122
143
|
getStageInstance(channelId: string): Promise<StageInstance>;
|
|
144
|
+
/** https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs */
|
|
123
145
|
listNitroStickerPacks(): Promise<{
|
|
124
146
|
stickerPacks: Array<JSONStickerPack>;
|
|
125
147
|
}>;
|
|
148
|
+
/** https://discord.com/developers/docs/resources/user#get-user */
|
|
126
149
|
getUser(userId?: string): Promise<User>;
|
|
150
|
+
/** https://discord.com/developers/docs/resources/user#get-current-user-guilds */
|
|
127
151
|
getGuilds(options?: {
|
|
128
152
|
before?: string;
|
|
129
153
|
after?: string;
|
|
@@ -139,10 +163,13 @@ export declare class Client extends EventEmitter {
|
|
|
139
163
|
approximate_member_count: number;
|
|
140
164
|
approximate_presence_count: number;
|
|
141
165
|
}>>;
|
|
166
|
+
/** https://discord.com/developers/docs/resources/voice#list-voice-regions */
|
|
142
167
|
listVoiceRegions(): Promise<Array<JSONVoiceRegion>>;
|
|
168
|
+
/** https://discord.com/developers/docs/topics/gateway#get-gateway */
|
|
143
169
|
getGateway(): Promise<{
|
|
144
170
|
url: string;
|
|
145
171
|
}>;
|
|
172
|
+
/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */
|
|
146
173
|
getGatewayBot(): Promise<{
|
|
147
174
|
url: string;
|
|
148
175
|
shards: number;
|
|
@@ -153,18 +180,26 @@ export declare class Client extends EventEmitter {
|
|
|
153
180
|
maxConcurrency: number;
|
|
154
181
|
};
|
|
155
182
|
}>;
|
|
183
|
+
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
|
156
184
|
updatePresence(options: {
|
|
157
|
-
since: number | null;
|
|
158
185
|
activities: Array<JSONActivity>;
|
|
159
186
|
status: StatusTypes;
|
|
160
187
|
afk: boolean;
|
|
161
188
|
}): void;
|
|
189
|
+
/** https://discord.com/developers/docs/topics/oauth2#get-current-bot-application-information */
|
|
162
190
|
getOAuth2Application(): Promise<Application>;
|
|
191
|
+
/** https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information */
|
|
163
192
|
getOAuth2Authorization(): Promise<{
|
|
164
193
|
application: Application;
|
|
165
194
|
scopes: Array<OAuth2Scopes>;
|
|
166
195
|
expires: number;
|
|
167
196
|
user?: User;
|
|
168
197
|
}>;
|
|
198
|
+
/** https://discord.com/developers/docs/topics/gateway#connections */
|
|
169
199
|
connect(): void;
|
|
200
|
+
disconnect(): void;
|
|
201
|
+
private onWebSocketOpen;
|
|
202
|
+
private onWebSocketMessage;
|
|
203
|
+
private onWebSocketError;
|
|
204
|
+
private onWebSocketClose;
|
|
170
205
|
}
|