@fluxerjs/core 1.2.0 → 1.2.2
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/index.d.mts +1166 -1021
- package/dist/index.d.ts +1166 -1021
- package/dist/index.js +2598 -2687
- package/dist/index.mjs +2718 -271
- package/package.json +8 -8
- package/dist/Channel-4YUSB2MM.mjs +0 -22
- package/dist/ClientUser-ET7FW3XL.mjs +0 -9
- package/dist/Guild-4U4U422Z.mjs +0 -12
- package/dist/GuildBan-7CXLTPKY.mjs +0 -7
- package/dist/GuildEmoji-OCXBPS6I.mjs +0 -8
- package/dist/GuildMember-FSGDPKUU.mjs +0 -9
- package/dist/GuildSticker-B7AZADJR.mjs +0 -8
- package/dist/Invite-UM5BU5A6.mjs +0 -7
- package/dist/Message-R7KSI5YU.mjs +0 -9
- package/dist/MessageReaction-EYO7AJTL.mjs +0 -8
- package/dist/Role-SERSJFJC.mjs +0 -7
- package/dist/Webhook-LWYP2BMI.mjs +0 -10
- package/dist/chunk-24E6OQID.mjs +0 -193
- package/dist/chunk-2ZSMLDEI.mjs +0 -114
- package/dist/chunk-3JVE6RW7.mjs +0 -147
- package/dist/chunk-6S3BDHBI.mjs +0 -28
- package/dist/chunk-75ODDXY3.mjs +0 -64
- package/dist/chunk-AH7KYH2Z.mjs +0 -50
- package/dist/chunk-BKPVGBOT.mjs +0 -8
- package/dist/chunk-G6F6VL4O.mjs +0 -54
- package/dist/chunk-HVCL7QLT.mjs +0 -337
- package/dist/chunk-IHXSHE2Z.mjs +0 -56
- package/dist/chunk-IRDYSGQO.mjs +0 -496
- package/dist/chunk-KR26CBFE.mjs +0 -58
- package/dist/chunk-QEXIYXXU.mjs +0 -62
- package/dist/chunk-U33GNMEZ.mjs +0 -140
- package/dist/chunk-UXIF75BV.mjs +0 -36
- package/dist/chunk-VJDH54HJ.mjs +0 -56
- package/dist/chunk-XNS4O6QJ.mjs +0 -7
- package/dist/chunk-YGXCMETR.mjs +0 -592
- package/dist/guildUtils-FTEGCNNJ.mjs +0 -17
package/dist/chunk-U33GNMEZ.mjs
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cdnDefaultAvatarURL
|
|
3
|
-
} from "./chunk-G6F6VL4O.mjs";
|
|
4
|
-
import {
|
|
5
|
-
CDN_URL
|
|
6
|
-
} from "./chunk-BKPVGBOT.mjs";
|
|
7
|
-
import {
|
|
8
|
-
Base
|
|
9
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
10
|
-
|
|
11
|
-
// src/structures/User.ts
|
|
12
|
-
import { Routes } from "@fluxerjs/types";
|
|
13
|
-
var User = class extends Base {
|
|
14
|
-
client;
|
|
15
|
-
id;
|
|
16
|
-
username;
|
|
17
|
-
discriminator;
|
|
18
|
-
globalName;
|
|
19
|
-
avatar;
|
|
20
|
-
bot;
|
|
21
|
-
/** RGB avatar color (e.g. 7577782). Null if not set. */
|
|
22
|
-
avatarColor;
|
|
23
|
-
/** Public flags bitfield. Null if not set. */
|
|
24
|
-
flags;
|
|
25
|
-
/** Whether this is an official system user. */
|
|
26
|
-
system;
|
|
27
|
-
/** Banner hash (from profile, member, or invite context). Null when not available. */
|
|
28
|
-
banner;
|
|
29
|
-
/** @param data - API user from message author, GET /users/{id}, or GET /users/@me */
|
|
30
|
-
constructor(client, data) {
|
|
31
|
-
super();
|
|
32
|
-
this.client = client;
|
|
33
|
-
this.id = data.id;
|
|
34
|
-
this.username = data.username;
|
|
35
|
-
this.discriminator = data.discriminator;
|
|
36
|
-
this.globalName = data.global_name ?? null;
|
|
37
|
-
this.avatar = data.avatar ?? null;
|
|
38
|
-
this.bot = !!data.bot;
|
|
39
|
-
this.avatarColor = data.avatar_color ?? null;
|
|
40
|
-
this.flags = data.flags ?? data.public_flags ?? null;
|
|
41
|
-
this.system = !!data.system;
|
|
42
|
-
this.banner = data.banner ?? null;
|
|
43
|
-
}
|
|
44
|
-
/** Update mutable fields from fresh API data. Used by getOrCreateUser cache. */
|
|
45
|
-
_patch(data) {
|
|
46
|
-
this.username = data.username;
|
|
47
|
-
this.discriminator = data.discriminator;
|
|
48
|
-
this.globalName = data.global_name ?? null;
|
|
49
|
-
this.avatar = data.avatar ?? null;
|
|
50
|
-
if (data.avatar_color !== void 0) this.avatarColor = data.avatar_color;
|
|
51
|
-
if (data.flags !== void 0) this.flags = data.flags;
|
|
52
|
-
if (data.banner !== void 0) this.banner = data.banner;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get the URL for this user's avatar.
|
|
56
|
-
* Auto-detects animated avatars (hash starting with `a_`) and uses gif extension.
|
|
57
|
-
* @param options - Optional `size` and `extension` (default: png, or gif for animated)
|
|
58
|
-
*/
|
|
59
|
-
avatarURL(options) {
|
|
60
|
-
if (!this.avatar) return null;
|
|
61
|
-
const ext = this.avatar.startsWith("a_") ? "gif" : options?.extension ?? "png";
|
|
62
|
-
const size = options?.size ? `?size=${options.size}` : "";
|
|
63
|
-
return `${CDN_URL}/avatars/${this.id}/${this.avatar}.${ext}${size}`;
|
|
64
|
-
}
|
|
65
|
-
/** Get the avatar URL, or the default avatar if none set (Fluxer: fluxerstatic.com). */
|
|
66
|
-
displayAvatarURL(options) {
|
|
67
|
-
return this.avatarURL(options) ?? cdnDefaultAvatarURL(this.id);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Get the URL for this user's banner.
|
|
71
|
-
* Returns null if the user has no banner (only available when fetched from profile/member context).
|
|
72
|
-
*/
|
|
73
|
-
bannerURL(options) {
|
|
74
|
-
if (!this.banner) return null;
|
|
75
|
-
const ext = this.banner.startsWith("a_") ? "gif" : options?.extension ?? "png";
|
|
76
|
-
const size = options?.size ? `?size=${options.size}` : "";
|
|
77
|
-
return `${CDN_URL}/banners/${this.id}/${this.banner}.${ext}${size}`;
|
|
78
|
-
}
|
|
79
|
-
/** Returns a mention string (e.g. `<@123456>`). */
|
|
80
|
-
toString() {
|
|
81
|
-
return `<@${this.id}>`;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Create or get a DM channel with this user.
|
|
85
|
-
* Returns the DM channel; use {@link DMChannel.send} to send messages.
|
|
86
|
-
*/
|
|
87
|
-
async createDM() {
|
|
88
|
-
const { DMChannel: DMChannelClass } = await import("./Channel-4YUSB2MM.mjs");
|
|
89
|
-
const data = await this.client.rest.post(Routes.userMeChannels(), {
|
|
90
|
-
body: { recipient_id: this.id },
|
|
91
|
-
auth: true
|
|
92
|
-
});
|
|
93
|
-
return new DMChannelClass(this.client, data);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Send a DM to this user.
|
|
97
|
-
* Convenience method that creates the DM channel and sends the message.
|
|
98
|
-
*/
|
|
99
|
-
async send(options) {
|
|
100
|
-
const dm = await this.createDM();
|
|
101
|
-
return dm.send(options);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// src/client/ClientUser.ts
|
|
106
|
-
import { Routes as Routes2 } from "@fluxerjs/types";
|
|
107
|
-
var ClientUser = class extends User {
|
|
108
|
-
constructor(client, data) {
|
|
109
|
-
super(client, { ...data });
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Fetch guilds the bot is a member of.
|
|
113
|
-
* @returns Array of Guild objects (cached in client.guilds)
|
|
114
|
-
*/
|
|
115
|
-
async fetchGuilds() {
|
|
116
|
-
const { Guild } = await import("./Guild-4U4U422Z.mjs");
|
|
117
|
-
const data = await this.client.rest.get(Routes2.currentUserGuilds());
|
|
118
|
-
const list = Array.isArray(data) ? data : data?.guilds ?? [];
|
|
119
|
-
const guilds = [];
|
|
120
|
-
for (const g of list) {
|
|
121
|
-
const guild = new Guild(this.client, g);
|
|
122
|
-
this.client.guilds.set(guild.id, guild);
|
|
123
|
-
guilds.push(guild);
|
|
124
|
-
}
|
|
125
|
-
return guilds;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Leave a guild. Requires the bot to be a member.
|
|
129
|
-
* @param guildId - The guild ID to leave
|
|
130
|
-
*/
|
|
131
|
-
async leaveGuild(guildId) {
|
|
132
|
-
await this.client.rest.delete(Routes2.leaveGuild(guildId), { auth: true });
|
|
133
|
-
this.client.guilds.delete(guildId);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export {
|
|
138
|
-
User,
|
|
139
|
-
ClientUser
|
|
140
|
-
};
|
package/dist/chunk-UXIF75BV.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Base
|
|
3
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/structures/GuildBan.ts
|
|
6
|
-
import { Routes } from "@fluxerjs/types";
|
|
7
|
-
var GuildBan = class extends Base {
|
|
8
|
-
client;
|
|
9
|
-
guildId;
|
|
10
|
-
user;
|
|
11
|
-
reason;
|
|
12
|
-
/** ISO timestamp when a temporary ban expires. Null for permanent bans. */
|
|
13
|
-
expiresAt;
|
|
14
|
-
/** @param data - API ban from GET /guilds/{id}/bans or gateway GUILD_BAN_ADD */
|
|
15
|
-
constructor(client, data, guildId) {
|
|
16
|
-
super();
|
|
17
|
-
this.client = client;
|
|
18
|
-
this.guildId = data.guild_id ?? guildId;
|
|
19
|
-
this.user = client.getOrCreateUser(data.user);
|
|
20
|
-
this.reason = data.reason ?? null;
|
|
21
|
-
this.expiresAt = data.expires_at ?? null;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Remove this ban (unban the user).
|
|
25
|
-
* Requires Ban Members permission.
|
|
26
|
-
*/
|
|
27
|
-
async unban() {
|
|
28
|
-
await this.client.rest.delete(Routes.guildBan(this.guildId, this.user.id), {
|
|
29
|
-
auth: true
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export {
|
|
35
|
-
GuildBan
|
|
36
|
-
};
|
package/dist/chunk-VJDH54HJ.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// src/util/messageUtils.ts
|
|
2
|
-
import { EmbedBuilder } from "@fluxerjs/builders";
|
|
3
|
-
var FILE_FETCH_TIMEOUT_MS = 3e4;
|
|
4
|
-
async function resolveMessageFiles(files) {
|
|
5
|
-
const result = [];
|
|
6
|
-
for (let i = 0; i < files.length; i++) {
|
|
7
|
-
const f = files[i];
|
|
8
|
-
const filename = f.filename ?? f.name;
|
|
9
|
-
if ("url" in f && f.url) {
|
|
10
|
-
if (!URL.canParse(f.url)) {
|
|
11
|
-
throw new Error(`Invalid file URL at index ${i}: ${f.url}`);
|
|
12
|
-
}
|
|
13
|
-
const res = await fetch(f.url, {
|
|
14
|
-
signal: AbortSignal.timeout(FILE_FETCH_TIMEOUT_MS)
|
|
15
|
-
});
|
|
16
|
-
if (!res.ok) {
|
|
17
|
-
throw new Error(`Failed to fetch file from ${f.url}: ${res.status} ${res.statusText}`);
|
|
18
|
-
}
|
|
19
|
-
const data = await res.arrayBuffer();
|
|
20
|
-
result.push({ name: f.name, data, filename });
|
|
21
|
-
} else if ("data" in f && f.data != null) {
|
|
22
|
-
result.push({ name: f.name, data: f.data, filename });
|
|
23
|
-
} else {
|
|
24
|
-
throw new Error(`File at index ${i} must have either "data" or "url"`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
function buildSendBody(options) {
|
|
30
|
-
const body = typeof options === "string" ? { content: options } : options;
|
|
31
|
-
const result = {};
|
|
32
|
-
if (body.content !== void 0) result.content = body.content;
|
|
33
|
-
if (body.embeds?.length) {
|
|
34
|
-
result.embeds = body.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
|
|
35
|
-
}
|
|
36
|
-
if (body.files?.length && body.attachments) {
|
|
37
|
-
result.attachments = body.attachments.map((a) => ({
|
|
38
|
-
id: a.id,
|
|
39
|
-
filename: a.filename,
|
|
40
|
-
...a.title != null && { title: a.title },
|
|
41
|
-
...a.description != null && { description: a.description },
|
|
42
|
-
...a.flags != null && { flags: a.flags }
|
|
43
|
-
}));
|
|
44
|
-
} else if (body.files?.length) {
|
|
45
|
-
result.attachments = body.files.map((f, i) => ({
|
|
46
|
-
id: i,
|
|
47
|
-
filename: f.filename ?? f.name
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export {
|
|
54
|
-
resolveMessageFiles,
|
|
55
|
-
buildSendBody
|
|
56
|
-
};
|