@fluxerjs/core 1.0.6 → 1.0.7
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-BEZOW4VC.mjs +17 -0
- package/dist/Channel-DPLLHL7Y.mjs +19 -0
- package/dist/Channel-KOTARBSF.mjs +17 -0
- package/dist/Channel-ON7O3D3M.mjs +17 -0
- package/dist/Channel-OSOB6ELO.mjs +19 -0
- package/dist/Channel-YVGPVOVB.mjs +17 -0
- package/dist/ClientUser-6HBAPU6H.mjs +8 -0
- package/dist/ClientUser-ALGC4FNY.mjs +8 -0
- package/dist/ClientUser-LLL6WX35.mjs +8 -0
- package/dist/ClientUser-N7ZXYAQ3.mjs +8 -0
- package/dist/Guild-5UBZNIGD.mjs +9 -0
- package/dist/Guild-GIXJJBFM.mjs +9 -0
- package/dist/Guild-S436SLOP.mjs +9 -0
- package/dist/Guild-WAFXK2EX.mjs +9 -0
- package/dist/Guild-XPOMHZZG.mjs +9 -0
- package/dist/GuildMember-BJJNCL6W.mjs +8 -0
- package/dist/GuildMember-FX2JAWES.mjs +8 -0
- package/dist/GuildMember-K5FLBNHV.mjs +8 -0
- package/dist/GuildMember-UBNHZBCO.mjs +8 -0
- package/dist/GuildMember-UU26WJGN.mjs +8 -0
- package/dist/Message-6RSAGIRP.mjs +8 -0
- package/dist/Message-OXTQHFCF.mjs +8 -0
- package/dist/Message-QXPHQOVC.mjs +8 -0
- package/dist/Message-R7GZYIQQ.mjs +8 -0
- package/dist/Message-W624MHJF.mjs +8 -0
- package/dist/Message-ZCS7IGJX.mjs +8 -0
- package/dist/Webhook-AG6QFM2I.mjs +7 -0
- package/dist/Webhook-TGAZZRQQ.mjs +7 -0
- package/dist/chunk-2FIZRRSO.mjs +88 -0
- package/dist/chunk-5HQRX3KJ.mjs +70 -0
- package/dist/chunk-62S4AB2S.mjs +54 -0
- package/dist/chunk-7SIS5CUA.mjs +14 -0
- package/dist/chunk-BGJSL6JI.mjs +14 -0
- package/dist/chunk-BYTAODAO.mjs +70 -0
- package/dist/chunk-CQ5ZVTLX.mjs +71 -0
- package/dist/chunk-DJBCSVZX.mjs +102 -0
- package/dist/chunk-DLROMCIJ.mjs +50 -0
- package/dist/chunk-DPZHAYCK.mjs +71 -0
- package/dist/chunk-E75ZVY3I.mjs +14 -0
- package/dist/chunk-FK5X6HFL.mjs +111 -0
- package/dist/chunk-FNFID6QB.mjs +45 -0
- package/dist/chunk-G4L7WAJS.mjs +64 -0
- package/dist/chunk-IPHFDI2L.mjs +68 -0
- package/dist/chunk-J3EIGOXQ.mjs +72 -0
- package/dist/chunk-JJHZBWZM.mjs +118 -0
- package/dist/chunk-LVMFPATK.mjs +54 -0
- package/dist/chunk-NISGA2YZ.mjs +55 -0
- package/dist/chunk-NOLYW3V4.mjs +140 -0
- package/dist/chunk-PO5JZQVN.mjs +111 -0
- package/dist/chunk-PYYXC7US.mjs +76 -0
- package/dist/chunk-QXJNV5EJ.mjs +110 -0
- package/dist/chunk-RXHJYGSJ.mjs +53 -0
- package/dist/chunk-T2NSVWBH.mjs +77 -0
- package/dist/chunk-TMDZALIN.mjs +110 -0
- package/dist/chunk-WYSHH4LR.mjs +141 -0
- package/dist/chunk-WZVY7DA6.mjs +44 -0
- package/dist/chunk-XTDZQD4A.mjs +110 -0
- package/dist/chunk-YKP7JHV2.mjs +102 -0
- package/dist/chunk-YSKZR66G.mjs +102 -0
- package/dist/chunk-ZMIMAMO2.mjs +14 -0
- package/dist/index.d.mts +206 -53
- package/dist/index.d.ts +206 -53
- package/dist/index.js +357 -179
- package/dist/index.mjs +38 -25
- package/package.json +7 -7
|
@@ -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-R7GZYIQQ.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,7 +1,7 @@
|
|
|
1
|
+
import { Collection } from '@fluxerjs/collection';
|
|
1
2
|
import * as _fluxerjs_types from '@fluxerjs/types';
|
|
2
|
-
import {
|
|
3
|
+
import { APIWebhook, APIChannelPartial, ChannelType, APIChannel, APIMessageAttachment, APIMessage, APIEmbed, APIUserPartial, APIGuild, APIGuildMember, GatewayPresenceUpdateData, GatewaySendPayload, Routes, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData } from '@fluxerjs/types';
|
|
3
4
|
export { GatewayOpcodes, Routes } from '@fluxerjs/types';
|
|
4
|
-
import { Collection } from '@fluxerjs/collection';
|
|
5
5
|
import { EmbedBuilder } from '@fluxerjs/builders';
|
|
6
6
|
export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
@@ -12,56 +12,17 @@ declare abstract class Base {
|
|
|
12
12
|
abstract readonly client: Client;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
readonly client: Client;
|
|
17
|
-
readonly id: string;
|
|
18
|
-
username: string;
|
|
19
|
-
discriminator: string;
|
|
20
|
-
globalName: string | null;
|
|
21
|
-
avatar: string | null;
|
|
22
|
-
readonly bot: boolean;
|
|
23
|
-
constructor(client: Client, data: APIUserPartial);
|
|
24
|
-
avatarURL(options?: {
|
|
25
|
-
size?: number;
|
|
26
|
-
extension?: string;
|
|
27
|
-
}): string | null;
|
|
28
|
-
displayAvatarURL(options?: {
|
|
29
|
-
size?: number;
|
|
30
|
-
}): string;
|
|
31
|
-
toString(): string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Options for editing a message (content and/or embeds). */
|
|
35
|
-
interface MessageEditOptions {
|
|
36
|
-
content?: string;
|
|
37
|
-
embeds?: (APIEmbed | EmbedBuilder)[];
|
|
38
|
-
}
|
|
39
|
-
declare class Message extends Base {
|
|
40
|
-
readonly client: Client;
|
|
41
|
-
readonly id: string;
|
|
42
|
-
readonly channelId: string;
|
|
43
|
-
readonly guildId: string | null;
|
|
44
|
-
readonly author: User;
|
|
45
|
-
content: string;
|
|
46
|
-
readonly createdAt: Date;
|
|
47
|
-
readonly editedAt: Date | null;
|
|
48
|
-
pinned: boolean;
|
|
49
|
-
readonly attachments: Collection<string, APIMessageAttachment>;
|
|
50
|
-
channel?: Channel;
|
|
51
|
-
constructor(client: Client, data: APIMessage);
|
|
52
|
-
reply(options: string | {
|
|
53
|
-
content?: string;
|
|
54
|
-
embeds?: APIEmbed[];
|
|
55
|
-
}): Promise<Message>;
|
|
56
|
-
edit(options: MessageEditOptions): Promise<Message>;
|
|
57
|
-
delete(): Promise<void>;
|
|
58
|
-
}
|
|
59
|
-
|
|
15
|
+
/** Options for sending a message via webhook. */
|
|
60
16
|
interface WebhookSendOptions {
|
|
17
|
+
/** Message text content */
|
|
61
18
|
content?: string;
|
|
19
|
+
/** Embed objects (use EmbedBuilder.toJSON()) */
|
|
62
20
|
embeds?: Array<Record<string, unknown>>;
|
|
21
|
+
/** Override the webhook's default username */
|
|
63
22
|
username?: string;
|
|
23
|
+
/** Override the webhook's default avatar URL */
|
|
64
24
|
avatar_url?: string;
|
|
25
|
+
/** Text-to-speech */
|
|
65
26
|
tts?: boolean;
|
|
66
27
|
}
|
|
67
28
|
/**
|
|
@@ -77,6 +38,7 @@ declare class Webhook extends Base {
|
|
|
77
38
|
avatar: string | null;
|
|
78
39
|
/** Present only when webhook was created via createWebhook(); not returned when fetching. */
|
|
79
40
|
readonly token: string | null;
|
|
41
|
+
/** @param data - API webhook from POST /channels/{id}/webhooks (has token) or GET /webhooks/{id} (no token) */
|
|
80
42
|
constructor(client: Client, data: APIWebhook & {
|
|
81
43
|
token?: string | null;
|
|
82
44
|
});
|
|
@@ -88,12 +50,18 @@ declare class Webhook extends Base {
|
|
|
88
50
|
*/
|
|
89
51
|
send(options: string | WebhookSendOptions): Promise<void>;
|
|
90
52
|
/**
|
|
91
|
-
* Fetch a webhook by ID using bot auth.
|
|
53
|
+
* Fetch a webhook by ID using bot auth.
|
|
54
|
+
* @param client - The client instance
|
|
55
|
+
* @param webhookId - The webhook ID
|
|
56
|
+
* @returns Webhook without token (cannot send)
|
|
92
57
|
*/
|
|
93
58
|
static fetch(client: Client, webhookId: string): Promise<Webhook>;
|
|
94
59
|
/**
|
|
95
60
|
* Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
|
|
96
|
-
*
|
|
61
|
+
* @param client - The client instance
|
|
62
|
+
* @param webhookId - The webhook ID
|
|
63
|
+
* @param token - The webhook token (from createWebhook or stored)
|
|
64
|
+
* @param options - Optional channelId, guildId, name for display
|
|
97
65
|
*/
|
|
98
66
|
static fromToken(client: Client, webhookId: string, token: string, options?: {
|
|
99
67
|
channelId?: string;
|
|
@@ -102,11 +70,20 @@ declare class Webhook extends Base {
|
|
|
102
70
|
}): Webhook;
|
|
103
71
|
}
|
|
104
72
|
|
|
73
|
+
/** Base class for all channel types. */
|
|
105
74
|
declare abstract class Channel extends Base {
|
|
75
|
+
/** Create a DM channel from API data (type DM or GroupDM). */
|
|
76
|
+
static createDM(client: Client, data: APIChannelPartial): DMChannel;
|
|
106
77
|
readonly client: Client;
|
|
107
78
|
readonly id: string;
|
|
108
79
|
type: ChannelType;
|
|
80
|
+
/** @param data - API channel from GET /channels/{id} or GET /guilds/{id}/channels */
|
|
109
81
|
constructor(client: Client, data: APIChannelPartial);
|
|
82
|
+
/**
|
|
83
|
+
* Create the appropriate channel subclass from API data.
|
|
84
|
+
* @param client - The client instance
|
|
85
|
+
* @param data - Channel data from the API
|
|
86
|
+
*/
|
|
110
87
|
static from(client: Client, data: APIChannel | APIChannelPartial): GuildChannel | TextChannel | null;
|
|
111
88
|
}
|
|
112
89
|
declare class GuildChannel extends Channel {
|
|
@@ -115,12 +92,19 @@ declare class GuildChannel extends Channel {
|
|
|
115
92
|
position?: number;
|
|
116
93
|
parentId: string | null;
|
|
117
94
|
constructor(client: Client, data: APIChannel);
|
|
118
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Create a webhook in this channel.
|
|
97
|
+
* @param options - Webhook name and optional avatar URL
|
|
98
|
+
* @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
|
|
99
|
+
*/
|
|
119
100
|
createWebhook(options: {
|
|
120
101
|
name: string;
|
|
121
102
|
avatar?: string | null;
|
|
122
103
|
}): Promise<Webhook>;
|
|
123
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* Fetch all webhooks in this channel.
|
|
106
|
+
* @returns Webhooks (includes token when listing from channel; can send via send())
|
|
107
|
+
*/
|
|
124
108
|
fetchWebhooks(): Promise<Webhook[]>;
|
|
125
109
|
}
|
|
126
110
|
declare class TextChannel extends GuildChannel {
|
|
@@ -129,6 +113,10 @@ declare class TextChannel extends GuildChannel {
|
|
|
129
113
|
rateLimitPerUser?: number;
|
|
130
114
|
lastMessageId?: string | null;
|
|
131
115
|
constructor(client: Client, data: APIChannel);
|
|
116
|
+
/**
|
|
117
|
+
* Send a message to this channel.
|
|
118
|
+
* @param options - Text content or object with `content` and/or `embeds`
|
|
119
|
+
*/
|
|
132
120
|
send(options: string | {
|
|
133
121
|
content?: string;
|
|
134
122
|
embeds?: unknown[];
|
|
@@ -146,7 +134,135 @@ declare class LinkChannel extends GuildChannel {
|
|
|
146
134
|
url?: string | null;
|
|
147
135
|
constructor(client: Client, data: APIChannel);
|
|
148
136
|
}
|
|
137
|
+
/** DM channel (direct message between bot and a user). */
|
|
138
|
+
declare class DMChannel extends Channel {
|
|
139
|
+
lastMessageId?: string | null;
|
|
140
|
+
constructor(client: Client, data: APIChannelPartial);
|
|
141
|
+
/**
|
|
142
|
+
* Send a message to this DM channel.
|
|
143
|
+
* @param options - Text content or object with `content` and/or `embeds`
|
|
144
|
+
*/
|
|
145
|
+
send(options: string | {
|
|
146
|
+
content?: string;
|
|
147
|
+
embeds?: unknown[];
|
|
148
|
+
}): Promise<Message>;
|
|
149
|
+
}
|
|
149
150
|
|
|
151
|
+
/** Options for editing a message (content and/or embeds). */
|
|
152
|
+
interface MessageEditOptions {
|
|
153
|
+
/** New text content */
|
|
154
|
+
content?: string;
|
|
155
|
+
/** New embeds (replaces existing) */
|
|
156
|
+
embeds?: (APIEmbed | EmbedBuilder)[];
|
|
157
|
+
}
|
|
158
|
+
/** Represents a message in a channel. */
|
|
159
|
+
declare class Message extends Base {
|
|
160
|
+
readonly client: Client;
|
|
161
|
+
readonly id: string;
|
|
162
|
+
readonly channelId: string;
|
|
163
|
+
readonly guildId: string | null;
|
|
164
|
+
readonly author: User;
|
|
165
|
+
content: string;
|
|
166
|
+
readonly createdAt: Date;
|
|
167
|
+
readonly editedAt: Date | null;
|
|
168
|
+
pinned: boolean;
|
|
169
|
+
readonly attachments: Collection<string, APIMessageAttachment>;
|
|
170
|
+
channel?: Channel;
|
|
171
|
+
/** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
|
|
172
|
+
constructor(client: Client, data: APIMessage);
|
|
173
|
+
/**
|
|
174
|
+
* Reply to this message.
|
|
175
|
+
* @param options - Text content or object with content and/or embeds
|
|
176
|
+
*/
|
|
177
|
+
reply(options: string | {
|
|
178
|
+
content?: string;
|
|
179
|
+
embeds?: APIEmbed[];
|
|
180
|
+
}): Promise<Message>;
|
|
181
|
+
/**
|
|
182
|
+
* Edit this message. Only the author (or admins) can edit.
|
|
183
|
+
* @param options - New content and/or embeds
|
|
184
|
+
*/
|
|
185
|
+
edit(options: MessageEditOptions): Promise<Message>;
|
|
186
|
+
/** Delete this message. */
|
|
187
|
+
delete(): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Format emoji for reaction API: unicode string or "name:id" for custom.
|
|
190
|
+
* @param emoji - Unicode emoji (e.g. "👍") or custom { name, id } or "name:id" string
|
|
191
|
+
*/
|
|
192
|
+
private static formatEmoji;
|
|
193
|
+
/**
|
|
194
|
+
* Add a reaction to this message (as the bot).
|
|
195
|
+
* @param emoji - Unicode emoji (e.g. `👍`) or custom emoji `{ name, id }`
|
|
196
|
+
*/
|
|
197
|
+
react(emoji: string | {
|
|
198
|
+
name: string;
|
|
199
|
+
id: string;
|
|
200
|
+
}): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Remove the bot's reaction, or a specific user's reaction if userId is provided.
|
|
203
|
+
* @param emoji - Unicode emoji or custom `{ name, id }`
|
|
204
|
+
* @param userId - If provided, removes that user's reaction (requires moderator permissions)
|
|
205
|
+
*/
|
|
206
|
+
removeReaction(emoji: string | {
|
|
207
|
+
name: string;
|
|
208
|
+
id: string;
|
|
209
|
+
}, userId?: string): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Remove all reactions from this message.
|
|
212
|
+
* Requires moderator permissions.
|
|
213
|
+
*/
|
|
214
|
+
removeAllReactions(): Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* Remove all reactions of a specific emoji from this message.
|
|
217
|
+
* @param emoji - Unicode emoji or custom `{ name, id }`. Requires moderator permissions.
|
|
218
|
+
*/
|
|
219
|
+
removeReactionEmoji(emoji: string | {
|
|
220
|
+
name: string;
|
|
221
|
+
id: string;
|
|
222
|
+
}): Promise<void>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Represents a user (or bot) on Fluxer. */
|
|
226
|
+
declare class User extends Base {
|
|
227
|
+
readonly client: Client;
|
|
228
|
+
readonly id: string;
|
|
229
|
+
username: string;
|
|
230
|
+
discriminator: string;
|
|
231
|
+
globalName: string | null;
|
|
232
|
+
avatar: string | null;
|
|
233
|
+
readonly bot: boolean;
|
|
234
|
+
/** @param data - API user from message author, GET /users/{id}, or GET /users/@me */
|
|
235
|
+
constructor(client: Client, data: APIUserPartial);
|
|
236
|
+
/**
|
|
237
|
+
* Get the URL for this user's avatar.
|
|
238
|
+
* @param options - Optional `size` and `extension` (default: `png`)
|
|
239
|
+
*/
|
|
240
|
+
avatarURL(options?: {
|
|
241
|
+
size?: number;
|
|
242
|
+
extension?: string;
|
|
243
|
+
}): string | null;
|
|
244
|
+
/** Get the avatar URL, or the default avatar if none set. */
|
|
245
|
+
displayAvatarURL(options?: {
|
|
246
|
+
size?: number;
|
|
247
|
+
}): string;
|
|
248
|
+
/** Returns a mention string (e.g. `<@123456>`). */
|
|
249
|
+
toString(): string;
|
|
250
|
+
/**
|
|
251
|
+
* Create or get a DM channel with this user.
|
|
252
|
+
* Returns the DM channel; use {@link DMChannel.send} to send messages.
|
|
253
|
+
*/
|
|
254
|
+
createDM(): Promise<DMChannel>;
|
|
255
|
+
/**
|
|
256
|
+
* Send a DM to this user.
|
|
257
|
+
* Convenience method that creates the DM channel and sends the message.
|
|
258
|
+
*/
|
|
259
|
+
send(options: string | {
|
|
260
|
+
content?: string;
|
|
261
|
+
embeds?: unknown[];
|
|
262
|
+
}): Promise<Message>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** Represents a Fluxer guild (server). */
|
|
150
266
|
declare class Guild extends Base {
|
|
151
267
|
readonly client: Client;
|
|
152
268
|
readonly id: string;
|
|
@@ -156,17 +272,27 @@ declare class Guild extends Base {
|
|
|
156
272
|
readonly ownerId: string;
|
|
157
273
|
members: Collection<string, GuildMember>;
|
|
158
274
|
channels: Collection<string, GuildChannel>;
|
|
275
|
+
/** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
|
|
159
276
|
constructor(client: Client, data: APIGuild);
|
|
277
|
+
/** Get the guild icon URL, or null if no icon. */
|
|
160
278
|
iconURL(options?: {
|
|
161
279
|
size?: number;
|
|
162
280
|
}): string | null;
|
|
281
|
+
/** Get the guild banner URL, or null if no banner. */
|
|
163
282
|
bannerURL(options?: {
|
|
164
283
|
size?: number;
|
|
165
284
|
}): string | null;
|
|
285
|
+
/**
|
|
286
|
+
* Fetch a guild member by user ID.
|
|
287
|
+
* @param userId - The user ID of the member to fetch
|
|
288
|
+
* @returns The guild member, or null if not found
|
|
289
|
+
*/
|
|
290
|
+
fetchMember(userId: string): Promise<GuildMember | null>;
|
|
166
291
|
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
167
292
|
fetchWebhooks(): Promise<Webhook[]>;
|
|
168
293
|
}
|
|
169
294
|
|
|
295
|
+
/** Represents a member of a guild. */
|
|
170
296
|
declare class GuildMember extends Base {
|
|
171
297
|
readonly client: Client;
|
|
172
298
|
readonly id: string;
|
|
@@ -176,10 +302,24 @@ declare class GuildMember extends Base {
|
|
|
176
302
|
readonly roles: string[];
|
|
177
303
|
readonly joinedAt: Date;
|
|
178
304
|
communicationDisabledUntil: Date | null;
|
|
305
|
+
/** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
|
|
179
306
|
constructor(client: Client, data: APIGuildMember & {
|
|
180
307
|
guild_id?: string;
|
|
181
308
|
}, guild: Guild);
|
|
309
|
+
/** Nickname, or global name, or username. */
|
|
182
310
|
get displayName(): string;
|
|
311
|
+
/**
|
|
312
|
+
* Add a role to this member.
|
|
313
|
+
* @param roleId - The role ID to add
|
|
314
|
+
* Requires Manage Roles permission.
|
|
315
|
+
*/
|
|
316
|
+
addRole(roleId: string): Promise<void>;
|
|
317
|
+
/**
|
|
318
|
+
* Remove a role from this member.
|
|
319
|
+
* @param roleId - The role ID to remove
|
|
320
|
+
* Requires Manage Roles permission.
|
|
321
|
+
*/
|
|
322
|
+
removeRole(roleId: string): Promise<void>;
|
|
183
323
|
}
|
|
184
324
|
|
|
185
325
|
interface ClientOptions {
|
|
@@ -262,6 +402,7 @@ interface ClientEvents {
|
|
|
262
402
|
[Events.Error]: [error: Error];
|
|
263
403
|
[Events.Debug]: [message: string];
|
|
264
404
|
}
|
|
405
|
+
/** Main Fluxer bot client. Connects to the gateway, emits events, and provides REST access. */
|
|
265
406
|
declare class Client extends EventEmitter {
|
|
266
407
|
readonly options: ClientOptions;
|
|
267
408
|
readonly rest: REST;
|
|
@@ -271,13 +412,25 @@ declare class Client extends EventEmitter {
|
|
|
271
412
|
user: ClientUser | null;
|
|
272
413
|
readyAt: Date | null;
|
|
273
414
|
private _ws;
|
|
415
|
+
/** @param options - Token, REST config, WebSocket, presence, etc. */
|
|
274
416
|
constructor(options?: ClientOptions);
|
|
417
|
+
/** WebSocket manager. Throws if not logged in. */
|
|
275
418
|
get ws(): WebSocketManager;
|
|
276
|
-
/**
|
|
419
|
+
/**
|
|
420
|
+
* Send a payload to the gateway (e.g. Voice State Update).
|
|
421
|
+
* @param shardId - Shard ID (use 0 for single-shard)
|
|
422
|
+
* @param payload - Gateway payload to send
|
|
423
|
+
*/
|
|
277
424
|
sendToGateway(shardId: number, payload: GatewaySendPayload): void;
|
|
278
425
|
private handleDispatch;
|
|
426
|
+
/**
|
|
427
|
+
* Connect to the Fluxer gateway and authenticate.
|
|
428
|
+
* @param token - Bot token (e.g. from FLUXER_BOT_TOKEN)
|
|
429
|
+
*/
|
|
279
430
|
login(token: string): Promise<string>;
|
|
431
|
+
/** Disconnect from the gateway and clear cached data. */
|
|
280
432
|
destroy(): Promise<void>;
|
|
433
|
+
/** Returns true if the client has received Ready and `user` is set. */
|
|
281
434
|
isReady(): this is Client & {
|
|
282
435
|
user: NonNullable<Client['user']>;
|
|
283
436
|
};
|
|
@@ -293,4 +446,4 @@ declare const ErrorCodes: {
|
|
|
293
446
|
readonly InvalidToken: "INVALID_TOKEN";
|
|
294
447
|
};
|
|
295
448
|
|
|
296
|
-
export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, type MessageEditOptions, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };
|
|
449
|
+
export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, DMChannel, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, type MessageEditOptions, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };
|