wv3-discord.js 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/.wv3/discord-bot.json +6 -0
- package/README.md +45 -0
- package/index.d.ts +212 -0
- package/index.js +53 -0
- package/package.json +25 -0
- package/scripts/discord-savor.js +479 -0
- package/scripts/smoke.js +70 -0
- package/scripts/wv3-tools/client/base.js +92 -0
- package/scripts/wv3-tools/client/client.js +34 -0
- package/scripts/wv3-tools/utils/console.js +6 -0
- package/scripts/wv3-tools/utils/identity-gen.js +14 -0
- package/scripts/wv3-tools/utils/syncernizor.js +53 -0
- package/scripts/wv3-tools/utils/tasks.js +444 -0
- package/scripts/wv3-tools/utils/token-gen.js +90 -0
- package/scripts/wv3-tools/utils/wait.js +3 -0
- package/scripts/wv3-tools.js +1 -0
- package/src/WV3Client.js +64 -0
- package/src/WV3Hook.js +25 -0
- package/src/builders/AttachmentBuilder.js +21 -0
- package/src/builders/EmbedBuilder.js +87 -0
- package/src/builders/SlashCommandBuilder.js +177 -0
- package/src/client/Client.js +247 -0
- package/src/rest/REST.js +112 -0
- package/src/rest/Routes.js +14 -0
- package/src/structures/Channel.js +53 -0
- package/src/structures/Interaction.js +197 -0
- package/src/structures/Message.js +17 -0
- package/src/structures/User.js +25 -0
- package/src/utils/Collection.js +45 -0
- package/src/utils/Constants.js +68 -0
- package/src/utils/messages.js +107 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# wv3-discord.js
|
|
2
|
+
|
|
3
|
+
`wv3-discord.js` is a small Discord API library with a `discord.js`-inspired API.
|
|
4
|
+
|
|
5
|
+
It does not depend on `discord.js`.
|
|
6
|
+
|
|
7
|
+
Instead, it provides a focused compatibility layer for common bot patterns:
|
|
8
|
+
|
|
9
|
+
- websocket-backed `Client` and `WV3Client`
|
|
10
|
+
- `REST` and `Routes`
|
|
11
|
+
- `Collection`
|
|
12
|
+
- `GatewayIntentBits` and `Events`
|
|
13
|
+
- `SlashCommandBuilder`, `EmbedBuilder`, and `AttachmentBuilder`
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install wv3-discord.js
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const {
|
|
25
|
+
WV3Client,
|
|
26
|
+
GatewayIntentBits
|
|
27
|
+
} = require("wv3-discord.js");
|
|
28
|
+
|
|
29
|
+
const client = new WV3Client({
|
|
30
|
+
intents: [GatewayIntentBits.Guilds]
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
client.once("ready", () => {
|
|
34
|
+
console.log(`Logged in as ${client.user.tag}`);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
client.start(process.env.DISCORD_TOKEN);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API notes
|
|
41
|
+
|
|
42
|
+
- `WV3Client` extends this package's local `Client`.
|
|
43
|
+
- `createClient(options)` returns a new `WV3Client`.
|
|
44
|
+
- `client.start(token)` is an alias for `client.login(token)`.
|
|
45
|
+
- The current goal is practical compatibility for common slash-command bot flows, not a full one-to-one reimplementation of every `discord.js` feature.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
|
|
5
|
+
export interface ClientOptions {
|
|
6
|
+
intents?: number[] | number;
|
|
7
|
+
rest?: {
|
|
8
|
+
version?: string;
|
|
9
|
+
api?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface RESTRequestOptions {
|
|
14
|
+
body?: unknown;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
query?: Record<string, string | number | boolean | null | undefined>;
|
|
17
|
+
auth?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export declare class DiscordHTTPError extends Error {
|
|
21
|
+
readonly status: number;
|
|
22
|
+
readonly data: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare class REST {
|
|
26
|
+
constructor(options?: { version?: string; api?: string });
|
|
27
|
+
setToken(token: string): this;
|
|
28
|
+
request(method: string, route: string, options?: RESTRequestOptions): Promise<any>;
|
|
29
|
+
get(route: string, options?: Omit<RESTRequestOptions, "body">): Promise<any>;
|
|
30
|
+
post(route: string, options?: RESTRequestOptions): Promise<any>;
|
|
31
|
+
put(route: string, options?: RESTRequestOptions): Promise<any>;
|
|
32
|
+
patch(route: string, options?: RESTRequestOptions): Promise<any>;
|
|
33
|
+
delete(route: string, options?: RESTRequestOptions): Promise<any>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare class Collection<K, V> extends Map<K, V> {
|
|
37
|
+
first(): V | undefined;
|
|
38
|
+
map<T>(fn: (value: V, key: K, collection: Collection<K, V>) => T): T[];
|
|
39
|
+
filter(fn: (value: V, key: K, collection: Collection<K, V>) => boolean): Collection<K, V>;
|
|
40
|
+
find(fn: (value: V, key: K, collection: Collection<K, V>) => boolean): V | undefined;
|
|
41
|
+
toJSON(): V[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare class EmbedBuilder {
|
|
45
|
+
constructor(data?: Record<string, unknown>);
|
|
46
|
+
setTitle(value: string): this;
|
|
47
|
+
setDescription(value: string): this;
|
|
48
|
+
setURL(value: string): this;
|
|
49
|
+
setColor(value: number): this;
|
|
50
|
+
setTimestamp(value?: string | number | Date): this;
|
|
51
|
+
setImage(value: string): this;
|
|
52
|
+
setThumbnail(value: string): this;
|
|
53
|
+
setFooter(value: { text: string; icon_url?: string }): this;
|
|
54
|
+
setAuthor(value: { name: string; icon_url?: string; url?: string }): this;
|
|
55
|
+
addFields(...fields: Array<{ name: string; value: string; inline?: boolean } | Array<{ name: string; value: string; inline?: boolean }>>): this;
|
|
56
|
+
toJSON(): Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare class AttachmentBuilder {
|
|
60
|
+
constructor(attachment: unknown, options?: { name?: string; description?: string });
|
|
61
|
+
setName(name: string): this;
|
|
62
|
+
setDescription(description: string): this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface CommandOptionChoice {
|
|
66
|
+
name: string;
|
|
67
|
+
value: string | number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface CommandOptionData {
|
|
71
|
+
type: number;
|
|
72
|
+
name?: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
required?: boolean;
|
|
75
|
+
min_value?: number;
|
|
76
|
+
max_value?: number;
|
|
77
|
+
choices?: CommandOptionChoice[];
|
|
78
|
+
options?: CommandOptionData[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export declare class SlashCommandOptionBuilder {
|
|
82
|
+
setName(name: string): this;
|
|
83
|
+
setDescription(description: string): this;
|
|
84
|
+
setRequired(required?: boolean): this;
|
|
85
|
+
setMinValue(value: number): this;
|
|
86
|
+
setMaxValue(value: number): this;
|
|
87
|
+
addChoices(...choices: CommandOptionChoice[]): this;
|
|
88
|
+
toJSON(): CommandOptionData;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export declare class SlashCommandSubcommandBuilder {
|
|
92
|
+
setName(name: string): this;
|
|
93
|
+
setDescription(description: string): this;
|
|
94
|
+
addStringOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
95
|
+
addIntegerOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
96
|
+
addNumberOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
97
|
+
addBooleanOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
98
|
+
addAttachmentOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
99
|
+
toJSON(): CommandOptionData;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export declare class SlashCommandBuilder {
|
|
103
|
+
setName(name: string): this;
|
|
104
|
+
setDescription(description: string): this;
|
|
105
|
+
addStringOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
106
|
+
addIntegerOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
107
|
+
addNumberOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
108
|
+
addBooleanOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
109
|
+
addUserOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
110
|
+
addChannelOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
111
|
+
addRoleOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
112
|
+
addMentionableOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
113
|
+
addAttachmentOption(builder: (option: SlashCommandOptionBuilder) => SlashCommandOptionBuilder): this;
|
|
114
|
+
addSubcommand(builder: (option: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder): this;
|
|
115
|
+
toJSON(): { name?: string; description?: string; options?: CommandOptionData[] };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export declare class User {
|
|
119
|
+
id: string | null;
|
|
120
|
+
username: string;
|
|
121
|
+
discriminator: string;
|
|
122
|
+
avatar: string | null;
|
|
123
|
+
bot: boolean;
|
|
124
|
+
globalName: string | null;
|
|
125
|
+
readonly tag: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export declare class Message {
|
|
129
|
+
id: string | null;
|
|
130
|
+
content: string;
|
|
131
|
+
channelId: string | null;
|
|
132
|
+
author: User | null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export declare class CommandInteractionOptionResolver {
|
|
136
|
+
getSubcommand(required?: boolean): string | null;
|
|
137
|
+
getAttachment(name: string, required?: boolean): any;
|
|
138
|
+
getInteger(name: string, required?: boolean): number | null;
|
|
139
|
+
getNumber(name: string, required?: boolean): number | null;
|
|
140
|
+
getString(name: string, required?: boolean): string | null;
|
|
141
|
+
getBoolean(name: string, required?: boolean): boolean | null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export declare class ChatInputCommandInteraction {
|
|
145
|
+
readonly client: Client;
|
|
146
|
+
readonly commandName: string | null;
|
|
147
|
+
readonly user: User | null;
|
|
148
|
+
readonly deferred: boolean;
|
|
149
|
+
readonly replied: boolean;
|
|
150
|
+
readonly options: CommandInteractionOptionResolver;
|
|
151
|
+
isChatInputCommand(): boolean;
|
|
152
|
+
reply(payload: Record<string, unknown> | string): Promise<this>;
|
|
153
|
+
deferReply(payload?: Record<string, unknown>): Promise<this>;
|
|
154
|
+
editReply(payload: Record<string, unknown> | string): Promise<Message>;
|
|
155
|
+
followUp(payload: Record<string, unknown> | string): Promise<Message>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export declare class TextChannel {
|
|
159
|
+
readonly id: string | null;
|
|
160
|
+
isTextBased(): boolean;
|
|
161
|
+
send(payload: Record<string, unknown> | string): Promise<Message>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export declare class Client extends EventEmitter {
|
|
165
|
+
constructor(options?: ClientOptions);
|
|
166
|
+
readonly rest: REST;
|
|
167
|
+
readonly channels: {
|
|
168
|
+
fetch(id: string): Promise<TextChannel>;
|
|
169
|
+
};
|
|
170
|
+
commands: Collection<string, any>;
|
|
171
|
+
user: User | null;
|
|
172
|
+
login(token?: string): Promise<string>;
|
|
173
|
+
destroy(): Promise<void>;
|
|
174
|
+
isReady(): boolean;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export declare class WV3Client extends Client {
|
|
178
|
+
readonly brand: string;
|
|
179
|
+
readonly packageName: string;
|
|
180
|
+
wv3: {
|
|
181
|
+
token: string | null;
|
|
182
|
+
id: string | null;
|
|
183
|
+
guild: string | null;
|
|
184
|
+
};
|
|
185
|
+
constructor(options?: ClientOptions);
|
|
186
|
+
setWV3Config(options?: {
|
|
187
|
+
token?: string;
|
|
188
|
+
id?: string;
|
|
189
|
+
clientId?: string;
|
|
190
|
+
guild?: string;
|
|
191
|
+
guildId?: string;
|
|
192
|
+
}): this;
|
|
193
|
+
initWV3(options?: {
|
|
194
|
+
token?: string;
|
|
195
|
+
id?: string;
|
|
196
|
+
clientId?: string;
|
|
197
|
+
guild?: string;
|
|
198
|
+
guildId?: string;
|
|
199
|
+
}): Promise<this>;
|
|
200
|
+
start(token?: string): Promise<string>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export declare function createClient(options?: ClientOptions): WV3Client;
|
|
204
|
+
|
|
205
|
+
export declare const GatewayIntentBits: Readonly<Record<string, number>>;
|
|
206
|
+
export declare const Events: Readonly<Record<string, string>>;
|
|
207
|
+
export declare const InteractionType: Readonly<Record<string, number>>;
|
|
208
|
+
export declare const ApplicationCommandOptionType: Readonly<Record<string, number>>;
|
|
209
|
+
export declare const MessageFlags: Readonly<Record<string, number>>;
|
|
210
|
+
export declare const Routes: Readonly<Record<string, (...args: string[]) => string>>;
|
|
211
|
+
export declare const brand: "wv3-discord.js";
|
|
212
|
+
export declare const version: "1.0.0";
|
package/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const { Client, WV3Client, createClient } = require("./src/WV3Client");
|
|
2
|
+
const { REST, DiscordHTTPError } = require("./src/rest/REST");
|
|
3
|
+
const { Routes } = require("./src/rest/Routes");
|
|
4
|
+
const { Collection } = require("./src/utils/Collection");
|
|
5
|
+
const {
|
|
6
|
+
GatewayIntentBits,
|
|
7
|
+
Events,
|
|
8
|
+
InteractionType,
|
|
9
|
+
ApplicationCommandOptionType,
|
|
10
|
+
MessageFlags
|
|
11
|
+
} = require("./src/utils/Constants");
|
|
12
|
+
const { EmbedBuilder } = require("./src/builders/EmbedBuilder");
|
|
13
|
+
const { AttachmentBuilder } = require("./src/builders/AttachmentBuilder");
|
|
14
|
+
const {
|
|
15
|
+
SlashCommandBuilder,
|
|
16
|
+
SlashCommandOptionBuilder,
|
|
17
|
+
SlashCommandSubcommandBuilder
|
|
18
|
+
} = require("./src/builders/SlashCommandBuilder");
|
|
19
|
+
const { User, ClientUser } = require("./src/structures/User");
|
|
20
|
+
const { Message } = require("./src/structures/Message");
|
|
21
|
+
const { TextChannel } = require("./src/structures/Channel");
|
|
22
|
+
const {
|
|
23
|
+
ChatInputCommandInteraction,
|
|
24
|
+
CommandInteractionOptionResolver
|
|
25
|
+
} = require("./src/structures/Interaction");
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
Client,
|
|
29
|
+
WV3Client,
|
|
30
|
+
createClient,
|
|
31
|
+
REST,
|
|
32
|
+
Routes,
|
|
33
|
+
Collection,
|
|
34
|
+
GatewayIntentBits,
|
|
35
|
+
Events,
|
|
36
|
+
InteractionType,
|
|
37
|
+
ApplicationCommandOptionType,
|
|
38
|
+
MessageFlags,
|
|
39
|
+
EmbedBuilder,
|
|
40
|
+
AttachmentBuilder,
|
|
41
|
+
SlashCommandBuilder,
|
|
42
|
+
SlashCommandOptionBuilder,
|
|
43
|
+
SlashCommandSubcommandBuilder,
|
|
44
|
+
User,
|
|
45
|
+
ClientUser,
|
|
46
|
+
Message,
|
|
47
|
+
TextChannel,
|
|
48
|
+
ChatInputCommandInteraction,
|
|
49
|
+
CommandInteractionOptionResolver,
|
|
50
|
+
DiscordHTTPError,
|
|
51
|
+
version: "1.0.0",
|
|
52
|
+
brand: "wv3-discord.js"
|
|
53
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wv3-discord.js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A lightweight Discord API client with a discord.js-inspired API.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"discord",
|
|
10
|
+
"discord.js",
|
|
11
|
+
"bot",
|
|
12
|
+
"wrapper",
|
|
13
|
+
"wv3"
|
|
14
|
+
],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"savor": "node scripts/discord-savor.js",
|
|
19
|
+
"smoke": "node scripts/smoke.js"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"axios": "^1.13.6",
|
|
23
|
+
"discord.js": "^14.25.1"
|
|
24
|
+
}
|
|
25
|
+
}
|