@fluxerjs/core 1.0.2 → 1.0.5
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/dist/Channel-2WNJ445K.mjs +17 -0
- package/dist/Channel-KILNV5V3.mjs +17 -0
- package/dist/Channel-VENHOL7S.mjs +17 -0
- package/dist/ClientUser-J6HQVSDJ.mjs +9 -0
- package/dist/Guild-CA3W6DOD.mjs +8 -0
- package/dist/Guild-NHNQ5TIA.mjs +8 -0
- package/dist/Guild-ZOFF5LFR.mjs +8 -0
- package/dist/GuildMember-XF7K2R45.mjs +9 -0
- package/dist/Message-PZUU7ZFR.mjs +9 -0
- package/dist/Webhook-2RHBXH7R.mjs +7 -0
- package/dist/Webhook-NUQCJAWZ.mjs +7 -0
- package/dist/chunk-4DBGMFOQ.mjs +14 -0
- package/dist/chunk-72OY7B3D.mjs +72 -0
- package/dist/chunk-7FYM4D2E.mjs +50 -0
- package/dist/chunk-7GZN6JXT.mjs +50 -0
- package/dist/chunk-BUEXP5SZ.mjs +70 -0
- package/dist/chunk-EF32ILJL.mjs +102 -0
- package/dist/chunk-L25ON7WB.mjs +52 -0
- package/dist/chunk-QDCFQF6J.mjs +36 -0
- package/dist/chunk-QDNFJVVE.mjs +70 -0
- package/dist/chunk-SW6KNICI.mjs +52 -0
- package/dist/chunk-XXCBJJZE.mjs +88 -0
- package/dist/chunk-ZHRQQZ4X.mjs +102 -0
- package/dist/index.d.mts +66 -2
- package/dist/index.d.ts +66 -2
- package/dist/index.js +133 -15
- package/dist/index.mjs +31 -10
- package/package.json +7 -7
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CDN_URL
|
|
3
|
+
} from "./chunk-HQMYRYMY.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Base
|
|
6
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
7
|
+
|
|
8
|
+
// src/structures/User.ts
|
|
9
|
+
var User = class extends Base {
|
|
10
|
+
client;
|
|
11
|
+
/** Snowflake ID. */
|
|
12
|
+
id;
|
|
13
|
+
/** Username. */
|
|
14
|
+
username;
|
|
15
|
+
/** Discriminator (legacy). */
|
|
16
|
+
discriminator;
|
|
17
|
+
/** Global display name, or null. */
|
|
18
|
+
globalName;
|
|
19
|
+
/** Avatar hash, or null. */
|
|
20
|
+
avatar;
|
|
21
|
+
/** Whether this user is a bot. */
|
|
22
|
+
bot;
|
|
23
|
+
/** @internal */
|
|
24
|
+
constructor(client, data) {
|
|
25
|
+
super();
|
|
26
|
+
this.client = client;
|
|
27
|
+
this.id = data.id;
|
|
28
|
+
this.username = data.username;
|
|
29
|
+
this.discriminator = data.discriminator;
|
|
30
|
+
this.globalName = data.global_name ?? null;
|
|
31
|
+
this.avatar = data.avatar ?? null;
|
|
32
|
+
this.bot = !!data.bot;
|
|
33
|
+
}
|
|
34
|
+
/** CDN URL for the avatar. */
|
|
35
|
+
avatarURL(options) {
|
|
36
|
+
if (!this.avatar) return null;
|
|
37
|
+
const ext = options?.extension ?? "png";
|
|
38
|
+
const size = options?.size ? `?size=${options.size}` : "";
|
|
39
|
+
return `${CDN_URL}/avatars/${this.id}/${this.avatar}.${ext}${size}`;
|
|
40
|
+
}
|
|
41
|
+
/** Avatar URL or default avatar if none. */
|
|
42
|
+
displayAvatarURL(options) {
|
|
43
|
+
return this.avatarURL(options) ?? `${CDN_URL}/avatars/0/0.png`;
|
|
44
|
+
}
|
|
45
|
+
toString() {
|
|
46
|
+
return `<@${this.id}>`;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
User
|
|
52
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Base
|
|
3
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/structures/Channel.ts
|
|
6
|
+
import { ChannelType, Routes } from "@fluxerjs/types";
|
|
7
|
+
var Channel = class extends Base {
|
|
8
|
+
client;
|
|
9
|
+
id;
|
|
10
|
+
type;
|
|
11
|
+
constructor(client, data) {
|
|
12
|
+
super();
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.id = data.id;
|
|
15
|
+
this.type = data.type;
|
|
16
|
+
}
|
|
17
|
+
/** Create the appropriate channel instance from API data. */
|
|
18
|
+
static from(client, data) {
|
|
19
|
+
const type = data.type ?? 0;
|
|
20
|
+
if (type === ChannelType.GuildText) return new TextChannel(client, data);
|
|
21
|
+
if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
22
|
+
if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
23
|
+
if (type === ChannelType.GuildLink) return new LinkChannel(client, data);
|
|
24
|
+
return new GuildChannel(client, data);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var GuildChannel = class extends Channel {
|
|
28
|
+
guildId;
|
|
29
|
+
name;
|
|
30
|
+
position;
|
|
31
|
+
parentId;
|
|
32
|
+
constructor(client, data) {
|
|
33
|
+
super(client, data);
|
|
34
|
+
this.guildId = data.guild_id ?? "";
|
|
35
|
+
this.name = data.name ?? null;
|
|
36
|
+
this.position = data.position;
|
|
37
|
+
this.parentId = data.parent_id ?? null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var TextChannel = class extends GuildChannel {
|
|
41
|
+
topic;
|
|
42
|
+
nsfw;
|
|
43
|
+
rateLimitPerUser;
|
|
44
|
+
lastMessageId;
|
|
45
|
+
constructor(client, data) {
|
|
46
|
+
super(client, data);
|
|
47
|
+
this.topic = data.topic ?? null;
|
|
48
|
+
this.nsfw = data.nsfw ?? false;
|
|
49
|
+
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
50
|
+
this.lastMessageId = data.last_message_id ?? null;
|
|
51
|
+
}
|
|
52
|
+
/** Send a message to this channel. */
|
|
53
|
+
async send(options) {
|
|
54
|
+
const body = typeof options === "string" ? { content: options } : options;
|
|
55
|
+
const { Message } = await import("./Message-PZUU7ZFR.mjs");
|
|
56
|
+
const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
|
|
57
|
+
return new Message(this.client, data);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var CategoryChannel = class extends GuildChannel {
|
|
61
|
+
};
|
|
62
|
+
var VoiceChannel = class extends GuildChannel {
|
|
63
|
+
bitrate;
|
|
64
|
+
userLimit;
|
|
65
|
+
rtcRegion;
|
|
66
|
+
constructor(client, data) {
|
|
67
|
+
super(client, data);
|
|
68
|
+
this.bitrate = data.bitrate ?? null;
|
|
69
|
+
this.userLimit = data.user_limit ?? null;
|
|
70
|
+
this.rtcRegion = data.rtc_region ?? null;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var LinkChannel = class extends GuildChannel {
|
|
74
|
+
url;
|
|
75
|
+
constructor(client, data) {
|
|
76
|
+
super(client, data);
|
|
77
|
+
this.url = data.url ?? null;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
Channel,
|
|
83
|
+
GuildChannel,
|
|
84
|
+
TextChannel,
|
|
85
|
+
CategoryChannel,
|
|
86
|
+
VoiceChannel,
|
|
87
|
+
LinkChannel
|
|
88
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Base
|
|
3
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/structures/Channel.ts
|
|
6
|
+
import { ChannelType, Routes } from "@fluxerjs/types";
|
|
7
|
+
var Channel = class extends Base {
|
|
8
|
+
client;
|
|
9
|
+
id;
|
|
10
|
+
type;
|
|
11
|
+
constructor(client, data) {
|
|
12
|
+
super();
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.id = data.id;
|
|
15
|
+
this.type = data.type;
|
|
16
|
+
}
|
|
17
|
+
static from(client, data) {
|
|
18
|
+
const type = data.type ?? 0;
|
|
19
|
+
if (type === ChannelType.GuildText) return new TextChannel(client, data);
|
|
20
|
+
if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
21
|
+
if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
22
|
+
if (type === ChannelType.GuildLink) return new LinkChannel(client, data);
|
|
23
|
+
return new GuildChannel(client, data);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var GuildChannel = class extends Channel {
|
|
27
|
+
guildId;
|
|
28
|
+
name;
|
|
29
|
+
position;
|
|
30
|
+
parentId;
|
|
31
|
+
constructor(client, data) {
|
|
32
|
+
super(client, data);
|
|
33
|
+
this.guildId = data.guild_id ?? "";
|
|
34
|
+
this.name = data.name ?? null;
|
|
35
|
+
this.position = data.position;
|
|
36
|
+
this.parentId = data.parent_id ?? null;
|
|
37
|
+
}
|
|
38
|
+
/** Create a webhook in this channel. Returns the webhook with token (required for send()). */
|
|
39
|
+
async createWebhook(options) {
|
|
40
|
+
const { Webhook } = await import("./Webhook-2RHBXH7R.mjs");
|
|
41
|
+
const data = await this.client.rest.post(Routes.channelWebhooks(this.id), {
|
|
42
|
+
body: options,
|
|
43
|
+
auth: true
|
|
44
|
+
});
|
|
45
|
+
return new Webhook(this.client, data);
|
|
46
|
+
}
|
|
47
|
+
/** Fetch all webhooks in this channel. Returned webhooks do not include the token (cannot send). */
|
|
48
|
+
async fetchWebhooks() {
|
|
49
|
+
const { Webhook } = await import("./Webhook-2RHBXH7R.mjs");
|
|
50
|
+
const data = await this.client.rest.get(Routes.channelWebhooks(this.id));
|
|
51
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
52
|
+
return list.map((w) => new Webhook(this.client, w));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var TextChannel = class extends GuildChannel {
|
|
56
|
+
topic;
|
|
57
|
+
nsfw;
|
|
58
|
+
rateLimitPerUser;
|
|
59
|
+
lastMessageId;
|
|
60
|
+
constructor(client, data) {
|
|
61
|
+
super(client, data);
|
|
62
|
+
this.topic = data.topic ?? null;
|
|
63
|
+
this.nsfw = data.nsfw ?? false;
|
|
64
|
+
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
65
|
+
this.lastMessageId = data.last_message_id ?? null;
|
|
66
|
+
}
|
|
67
|
+
async send(options) {
|
|
68
|
+
const body = typeof options === "string" ? { content: options } : options;
|
|
69
|
+
const { Message } = await import("./Message-23Z3RPCZ.mjs");
|
|
70
|
+
const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
|
|
71
|
+
return new Message(this.client, data);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var CategoryChannel = class extends GuildChannel {
|
|
75
|
+
};
|
|
76
|
+
var VoiceChannel = class extends GuildChannel {
|
|
77
|
+
bitrate;
|
|
78
|
+
userLimit;
|
|
79
|
+
rtcRegion;
|
|
80
|
+
constructor(client, data) {
|
|
81
|
+
super(client, data);
|
|
82
|
+
this.bitrate = data.bitrate ?? null;
|
|
83
|
+
this.userLimit = data.user_limit ?? null;
|
|
84
|
+
this.rtcRegion = data.rtc_region ?? null;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var LinkChannel = class extends GuildChannel {
|
|
88
|
+
url;
|
|
89
|
+
constructor(client, data) {
|
|
90
|
+
super(client, data);
|
|
91
|
+
this.url = data.url ?? null;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
Channel,
|
|
97
|
+
GuildChannel,
|
|
98
|
+
TextChannel,
|
|
99
|
+
CategoryChannel,
|
|
100
|
+
VoiceChannel,
|
|
101
|
+
LinkChannel
|
|
102
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _fluxerjs_types from '@fluxerjs/types';
|
|
2
|
-
import { APIUserPartial, APIMessageAttachment, APIMessage, APIEmbed, ChannelType, APIChannelPartial, APIChannel, APIGuild, APIGuildMember, GatewaySendPayload, Routes, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData } from '@fluxerjs/types';
|
|
2
|
+
import { APIUserPartial, APIMessageAttachment, APIMessage, APIEmbed, APIWebhook, ChannelType, APIChannelPartial, APIChannel, APIGuild, APIGuildMember, GatewayPresenceUpdateData, GatewaySendPayload, Routes, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData } from '@fluxerjs/types';
|
|
3
3
|
export { GatewayOpcodes, Routes } from '@fluxerjs/types';
|
|
4
4
|
import { Collection } from '@fluxerjs/collection';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
@@ -53,6 +53,51 @@ declare class Message extends Base {
|
|
|
53
53
|
delete(): Promise<void>;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
interface WebhookSendOptions {
|
|
57
|
+
content?: string;
|
|
58
|
+
embeds?: Array<Record<string, unknown>>;
|
|
59
|
+
username?: string;
|
|
60
|
+
avatar_url?: string;
|
|
61
|
+
tts?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Represents a Discord/Fluxer webhook. Supports creating, fetching, sending, and deleting.
|
|
65
|
+
* The token is only available when the webhook was created; fetched webhooks cannot send messages.
|
|
66
|
+
*/
|
|
67
|
+
declare class Webhook extends Base {
|
|
68
|
+
readonly client: Client;
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly guildId: string;
|
|
71
|
+
readonly channelId: string;
|
|
72
|
+
name: string;
|
|
73
|
+
avatar: string | null;
|
|
74
|
+
/** Present only when webhook was created via createWebhook(); not returned when fetching. */
|
|
75
|
+
readonly token: string | null;
|
|
76
|
+
constructor(client: Client, data: APIWebhook & {
|
|
77
|
+
token?: string | null;
|
|
78
|
+
});
|
|
79
|
+
/** Delete this webhook. Requires bot token with Manage Webhooks permission. */
|
|
80
|
+
delete(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
|
|
83
|
+
* @throws Error if token is not available
|
|
84
|
+
*/
|
|
85
|
+
send(options: string | WebhookSendOptions): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Fetch a webhook by ID using bot auth. The returned webhook will not have a token (cannot send).
|
|
88
|
+
*/
|
|
89
|
+
static fetch(client: Client, webhookId: string): Promise<Webhook>;
|
|
90
|
+
/**
|
|
91
|
+
* Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
|
|
92
|
+
* Useful when you have the token from a previous createWebhook() call.
|
|
93
|
+
*/
|
|
94
|
+
static fromToken(client: Client, webhookId: string, token: string, options?: {
|
|
95
|
+
channelId?: string;
|
|
96
|
+
guildId?: string;
|
|
97
|
+
name?: string;
|
|
98
|
+
}): Webhook;
|
|
99
|
+
}
|
|
100
|
+
|
|
56
101
|
declare abstract class Channel extends Base {
|
|
57
102
|
readonly client: Client;
|
|
58
103
|
readonly id: string;
|
|
@@ -66,6 +111,13 @@ declare class GuildChannel extends Channel {
|
|
|
66
111
|
position?: number;
|
|
67
112
|
parentId: string | null;
|
|
68
113
|
constructor(client: Client, data: APIChannel);
|
|
114
|
+
/** Create a webhook in this channel. Returns the webhook with token (required for send()). */
|
|
115
|
+
createWebhook(options: {
|
|
116
|
+
name: string;
|
|
117
|
+
avatar?: string | null;
|
|
118
|
+
}): Promise<Webhook>;
|
|
119
|
+
/** Fetch all webhooks in this channel. Returned webhooks do not include the token (cannot send). */
|
|
120
|
+
fetchWebhooks(): Promise<Webhook[]>;
|
|
69
121
|
}
|
|
70
122
|
declare class TextChannel extends GuildChannel {
|
|
71
123
|
topic?: string | null;
|
|
@@ -107,6 +159,8 @@ declare class Guild extends Base {
|
|
|
107
159
|
bannerURL(options?: {
|
|
108
160
|
size?: number;
|
|
109
161
|
}): string | null;
|
|
162
|
+
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
163
|
+
fetchWebhooks(): Promise<Webhook[]>;
|
|
110
164
|
}
|
|
111
165
|
|
|
112
166
|
declare class GuildMember extends Base {
|
|
@@ -127,6 +181,8 @@ declare class GuildMember extends Base {
|
|
|
127
181
|
interface ClientOptions {
|
|
128
182
|
rest?: Partial<ConstructorParameters<typeof REST>[0]>;
|
|
129
183
|
intents?: number;
|
|
184
|
+
/** Initial presence (status, custom_status, etc.) sent on identify. Can also update via PresenceUpdate after connect. */
|
|
185
|
+
presence?: GatewayPresenceUpdateData;
|
|
130
186
|
/** Optional WebSocket constructor (e.g. `require('ws')` in Node for compatibility) */
|
|
131
187
|
WebSocket?: new (url: string) => {
|
|
132
188
|
send(data: string | ArrayBufferLike): void;
|
|
@@ -147,6 +203,10 @@ declare const Events: {
|
|
|
147
203
|
readonly MessageCreate: "messageCreate";
|
|
148
204
|
readonly MessageUpdate: "messageUpdate";
|
|
149
205
|
readonly MessageDelete: "messageDelete";
|
|
206
|
+
readonly MessageReactionAdd: "messageReactionAdd";
|
|
207
|
+
readonly MessageReactionRemove: "messageReactionRemove";
|
|
208
|
+
readonly MessageReactionRemoveAll: "messageReactionRemoveAll";
|
|
209
|
+
readonly MessageReactionRemoveEmoji: "messageReactionRemoveEmoji";
|
|
150
210
|
readonly InteractionCreate: "interactionCreate";
|
|
151
211
|
readonly GuildCreate: "guildCreate";
|
|
152
212
|
readonly GuildUpdate: "guildUpdate";
|
|
@@ -172,6 +232,10 @@ interface ClientEvents {
|
|
|
172
232
|
id: string;
|
|
173
233
|
channelId: string;
|
|
174
234
|
}];
|
|
235
|
+
[Events.MessageReactionAdd]: [data: GatewayMessageReactionAddDispatchData];
|
|
236
|
+
[Events.MessageReactionRemove]: [data: GatewayMessageReactionRemoveDispatchData];
|
|
237
|
+
[Events.MessageReactionRemoveAll]: [data: GatewayMessageReactionRemoveAllDispatchData];
|
|
238
|
+
[Events.MessageReactionRemoveEmoji]: [data: GatewayMessageReactionRemoveEmojiDispatchData];
|
|
175
239
|
[Events.InteractionCreate]: [interaction: _fluxerjs_types.APIApplicationCommandInteraction];
|
|
176
240
|
[Events.GuildCreate]: [guild: Guild];
|
|
177
241
|
[Events.GuildUpdate]: [oldGuild: Guild, newGuild: Guild];
|
|
@@ -225,4 +289,4 @@ declare const ErrorCodes: {
|
|
|
225
289
|
readonly InvalidToken: "INVALID_TOKEN";
|
|
226
290
|
};
|
|
227
291
|
|
|
228
|
-
export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, TextChannel, User, VoiceChannel };
|
|
292
|
+
export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _fluxerjs_types from '@fluxerjs/types';
|
|
2
|
-
import { APIUserPartial, APIMessageAttachment, APIMessage, APIEmbed, ChannelType, APIChannelPartial, APIChannel, APIGuild, APIGuildMember, GatewaySendPayload, Routes, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData } from '@fluxerjs/types';
|
|
2
|
+
import { APIUserPartial, APIMessageAttachment, APIMessage, APIEmbed, APIWebhook, ChannelType, APIChannelPartial, APIChannel, APIGuild, APIGuildMember, GatewayPresenceUpdateData, GatewaySendPayload, Routes, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData } from '@fluxerjs/types';
|
|
3
3
|
export { GatewayOpcodes, Routes } from '@fluxerjs/types';
|
|
4
4
|
import { Collection } from '@fluxerjs/collection';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
@@ -53,6 +53,51 @@ declare class Message extends Base {
|
|
|
53
53
|
delete(): Promise<void>;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
interface WebhookSendOptions {
|
|
57
|
+
content?: string;
|
|
58
|
+
embeds?: Array<Record<string, unknown>>;
|
|
59
|
+
username?: string;
|
|
60
|
+
avatar_url?: string;
|
|
61
|
+
tts?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Represents a Discord/Fluxer webhook. Supports creating, fetching, sending, and deleting.
|
|
65
|
+
* The token is only available when the webhook was created; fetched webhooks cannot send messages.
|
|
66
|
+
*/
|
|
67
|
+
declare class Webhook extends Base {
|
|
68
|
+
readonly client: Client;
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly guildId: string;
|
|
71
|
+
readonly channelId: string;
|
|
72
|
+
name: string;
|
|
73
|
+
avatar: string | null;
|
|
74
|
+
/** Present only when webhook was created via createWebhook(); not returned when fetching. */
|
|
75
|
+
readonly token: string | null;
|
|
76
|
+
constructor(client: Client, data: APIWebhook & {
|
|
77
|
+
token?: string | null;
|
|
78
|
+
});
|
|
79
|
+
/** Delete this webhook. Requires bot token with Manage Webhooks permission. */
|
|
80
|
+
delete(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
|
|
83
|
+
* @throws Error if token is not available
|
|
84
|
+
*/
|
|
85
|
+
send(options: string | WebhookSendOptions): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Fetch a webhook by ID using bot auth. The returned webhook will not have a token (cannot send).
|
|
88
|
+
*/
|
|
89
|
+
static fetch(client: Client, webhookId: string): Promise<Webhook>;
|
|
90
|
+
/**
|
|
91
|
+
* Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
|
|
92
|
+
* Useful when you have the token from a previous createWebhook() call.
|
|
93
|
+
*/
|
|
94
|
+
static fromToken(client: Client, webhookId: string, token: string, options?: {
|
|
95
|
+
channelId?: string;
|
|
96
|
+
guildId?: string;
|
|
97
|
+
name?: string;
|
|
98
|
+
}): Webhook;
|
|
99
|
+
}
|
|
100
|
+
|
|
56
101
|
declare abstract class Channel extends Base {
|
|
57
102
|
readonly client: Client;
|
|
58
103
|
readonly id: string;
|
|
@@ -66,6 +111,13 @@ declare class GuildChannel extends Channel {
|
|
|
66
111
|
position?: number;
|
|
67
112
|
parentId: string | null;
|
|
68
113
|
constructor(client: Client, data: APIChannel);
|
|
114
|
+
/** Create a webhook in this channel. Returns the webhook with token (required for send()). */
|
|
115
|
+
createWebhook(options: {
|
|
116
|
+
name: string;
|
|
117
|
+
avatar?: string | null;
|
|
118
|
+
}): Promise<Webhook>;
|
|
119
|
+
/** Fetch all webhooks in this channel. Returned webhooks do not include the token (cannot send). */
|
|
120
|
+
fetchWebhooks(): Promise<Webhook[]>;
|
|
69
121
|
}
|
|
70
122
|
declare class TextChannel extends GuildChannel {
|
|
71
123
|
topic?: string | null;
|
|
@@ -107,6 +159,8 @@ declare class Guild extends Base {
|
|
|
107
159
|
bannerURL(options?: {
|
|
108
160
|
size?: number;
|
|
109
161
|
}): string | null;
|
|
162
|
+
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
163
|
+
fetchWebhooks(): Promise<Webhook[]>;
|
|
110
164
|
}
|
|
111
165
|
|
|
112
166
|
declare class GuildMember extends Base {
|
|
@@ -127,6 +181,8 @@ declare class GuildMember extends Base {
|
|
|
127
181
|
interface ClientOptions {
|
|
128
182
|
rest?: Partial<ConstructorParameters<typeof REST>[0]>;
|
|
129
183
|
intents?: number;
|
|
184
|
+
/** Initial presence (status, custom_status, etc.) sent on identify. Can also update via PresenceUpdate after connect. */
|
|
185
|
+
presence?: GatewayPresenceUpdateData;
|
|
130
186
|
/** Optional WebSocket constructor (e.g. `require('ws')` in Node for compatibility) */
|
|
131
187
|
WebSocket?: new (url: string) => {
|
|
132
188
|
send(data: string | ArrayBufferLike): void;
|
|
@@ -147,6 +203,10 @@ declare const Events: {
|
|
|
147
203
|
readonly MessageCreate: "messageCreate";
|
|
148
204
|
readonly MessageUpdate: "messageUpdate";
|
|
149
205
|
readonly MessageDelete: "messageDelete";
|
|
206
|
+
readonly MessageReactionAdd: "messageReactionAdd";
|
|
207
|
+
readonly MessageReactionRemove: "messageReactionRemove";
|
|
208
|
+
readonly MessageReactionRemoveAll: "messageReactionRemoveAll";
|
|
209
|
+
readonly MessageReactionRemoveEmoji: "messageReactionRemoveEmoji";
|
|
150
210
|
readonly InteractionCreate: "interactionCreate";
|
|
151
211
|
readonly GuildCreate: "guildCreate";
|
|
152
212
|
readonly GuildUpdate: "guildUpdate";
|
|
@@ -172,6 +232,10 @@ interface ClientEvents {
|
|
|
172
232
|
id: string;
|
|
173
233
|
channelId: string;
|
|
174
234
|
}];
|
|
235
|
+
[Events.MessageReactionAdd]: [data: GatewayMessageReactionAddDispatchData];
|
|
236
|
+
[Events.MessageReactionRemove]: [data: GatewayMessageReactionRemoveDispatchData];
|
|
237
|
+
[Events.MessageReactionRemoveAll]: [data: GatewayMessageReactionRemoveAllDispatchData];
|
|
238
|
+
[Events.MessageReactionRemoveEmoji]: [data: GatewayMessageReactionRemoveEmojiDispatchData];
|
|
175
239
|
[Events.InteractionCreate]: [interaction: _fluxerjs_types.APIApplicationCommandInteraction];
|
|
176
240
|
[Events.GuildCreate]: [guild: Guild];
|
|
177
241
|
[Events.GuildUpdate]: [oldGuild: Guild, newGuild: Guild];
|
|
@@ -225,4 +289,4 @@ declare const ErrorCodes: {
|
|
|
225
289
|
readonly InvalidToken: "INVALID_TOKEN";
|
|
226
290
|
};
|
|
227
291
|
|
|
228
|
-
export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, TextChannel, User, VoiceChannel };
|
|
292
|
+
export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };
|