@fluxerjs/core 1.0.5 → 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-IKL3SJXN.mjs +17 -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-33APPS76.mjs +9 -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-3CNUPFDI.mjs +59 -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-OHIHIQAS.mjs +102 -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 +208 -51
- package/dist/index.d.ts +208 -51
- package/dist/index.js +361 -177
- package/dist/index.mjs +38 -25
- package/package.json +7 -7
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Base
|
|
3
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/util/Constants.ts
|
|
6
|
+
var CDN_URL = "https://fluxerusercontent.com";
|
|
7
|
+
|
|
8
|
+
// src/structures/User.ts
|
|
9
|
+
import { Routes } from "@fluxerjs/types";
|
|
10
|
+
var User = class extends Base {
|
|
11
|
+
client;
|
|
12
|
+
id;
|
|
13
|
+
username;
|
|
14
|
+
discriminator;
|
|
15
|
+
globalName;
|
|
16
|
+
avatar;
|
|
17
|
+
bot;
|
|
18
|
+
/** @param data - API user from message author, GET /users/{id}, or GET /users/@me */
|
|
19
|
+
constructor(client, data) {
|
|
20
|
+
super();
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.id = data.id;
|
|
23
|
+
this.username = data.username;
|
|
24
|
+
this.discriminator = data.discriminator;
|
|
25
|
+
this.globalName = data.global_name ?? null;
|
|
26
|
+
this.avatar = data.avatar ?? null;
|
|
27
|
+
this.bot = !!data.bot;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the URL for this user's avatar.
|
|
31
|
+
* @param options - Optional `size` and `extension` (default: `png`)
|
|
32
|
+
*/
|
|
33
|
+
avatarURL(options) {
|
|
34
|
+
if (!this.avatar) return null;
|
|
35
|
+
const ext = options?.extension ?? "png";
|
|
36
|
+
const size = options?.size ? `?size=${options.size}` : "";
|
|
37
|
+
return `${CDN_URL}/avatars/${this.id}/${this.avatar}.${ext}${size}`;
|
|
38
|
+
}
|
|
39
|
+
/** Get the avatar URL, or the default avatar if none set. */
|
|
40
|
+
displayAvatarURL(options) {
|
|
41
|
+
return this.avatarURL(options) ?? `${CDN_URL}/avatars/0/0.png`;
|
|
42
|
+
}
|
|
43
|
+
/** Returns a mention string (e.g. `<@123456>`). */
|
|
44
|
+
toString() {
|
|
45
|
+
return `<@${this.id}>`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create or get a DM channel with this user.
|
|
49
|
+
* Returns the DM channel; use {@link DMChannel.send} to send messages.
|
|
50
|
+
*/
|
|
51
|
+
async createDM() {
|
|
52
|
+
const { DMChannel: DMChannelClass } = await import("./Channel-OSOB6ELO.mjs");
|
|
53
|
+
const data = await this.client.rest.post(Routes.userMeChannels(), {
|
|
54
|
+
body: { recipient_id: this.id },
|
|
55
|
+
auth: true
|
|
56
|
+
});
|
|
57
|
+
return new DMChannelClass(this.client, data);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Send a DM to this user.
|
|
61
|
+
* Convenience method that creates the DM channel and sends the message.
|
|
62
|
+
*/
|
|
63
|
+
async send(options) {
|
|
64
|
+
const dm = await this.createDM();
|
|
65
|
+
return dm.send(options);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
CDN_URL,
|
|
71
|
+
User
|
|
72
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Create the appropriate channel subclass from API data.
|
|
19
|
+
* @param client - The client instance
|
|
20
|
+
* @param data - Channel data from the API
|
|
21
|
+
*/
|
|
22
|
+
static from(client, data) {
|
|
23
|
+
const type = data.type ?? 0;
|
|
24
|
+
if (type === ChannelType.GuildText) return new TextChannel(client, data);
|
|
25
|
+
if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
26
|
+
if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
27
|
+
if (type === ChannelType.GuildLink) return new LinkChannel(client, data);
|
|
28
|
+
return new GuildChannel(client, data);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var GuildChannel = class extends Channel {
|
|
32
|
+
guildId;
|
|
33
|
+
name;
|
|
34
|
+
position;
|
|
35
|
+
parentId;
|
|
36
|
+
constructor(client, data) {
|
|
37
|
+
super(client, data);
|
|
38
|
+
this.guildId = data.guild_id ?? "";
|
|
39
|
+
this.name = data.name ?? null;
|
|
40
|
+
this.position = data.position;
|
|
41
|
+
this.parentId = data.parent_id ?? null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a webhook in this channel.
|
|
45
|
+
* @param options - Webhook name and optional avatar URL
|
|
46
|
+
* @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
|
|
47
|
+
*/
|
|
48
|
+
async createWebhook(options) {
|
|
49
|
+
const { Webhook } = await import("./Webhook-AG6QFM2I.mjs");
|
|
50
|
+
const data = await this.client.rest.post(Routes.channelWebhooks(this.id), {
|
|
51
|
+
body: options,
|
|
52
|
+
auth: true
|
|
53
|
+
});
|
|
54
|
+
return new Webhook(this.client, data);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Fetch all webhooks in this channel.
|
|
58
|
+
* @returns Webhooks without token (cannot send). Requires Manage Webhooks permission.
|
|
59
|
+
*/
|
|
60
|
+
async fetchWebhooks() {
|
|
61
|
+
const { Webhook } = await import("./Webhook-AG6QFM2I.mjs");
|
|
62
|
+
const data = await this.client.rest.get(Routes.channelWebhooks(this.id));
|
|
63
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
64
|
+
return list.map((w) => new Webhook(this.client, w));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var TextChannel = class extends GuildChannel {
|
|
68
|
+
topic;
|
|
69
|
+
nsfw;
|
|
70
|
+
rateLimitPerUser;
|
|
71
|
+
lastMessageId;
|
|
72
|
+
constructor(client, data) {
|
|
73
|
+
super(client, data);
|
|
74
|
+
this.topic = data.topic ?? null;
|
|
75
|
+
this.nsfw = data.nsfw ?? false;
|
|
76
|
+
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
77
|
+
this.lastMessageId = data.last_message_id ?? null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Send a message to this channel.
|
|
81
|
+
* @param options - Text content or object with `content` and/or `embeds`
|
|
82
|
+
*/
|
|
83
|
+
async send(options) {
|
|
84
|
+
const body = typeof options === "string" ? { content: options } : options;
|
|
85
|
+
const { Message } = await import("./Message-QXPHQOVC.mjs");
|
|
86
|
+
const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
|
|
87
|
+
return new Message(this.client, data);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var CategoryChannel = class extends GuildChannel {
|
|
91
|
+
};
|
|
92
|
+
var VoiceChannel = class extends GuildChannel {
|
|
93
|
+
bitrate;
|
|
94
|
+
userLimit;
|
|
95
|
+
rtcRegion;
|
|
96
|
+
constructor(client, data) {
|
|
97
|
+
super(client, data);
|
|
98
|
+
this.bitrate = data.bitrate ?? null;
|
|
99
|
+
this.userLimit = data.user_limit ?? null;
|
|
100
|
+
this.rtcRegion = data.rtc_region ?? null;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var LinkChannel = class extends GuildChannel {
|
|
104
|
+
url;
|
|
105
|
+
constructor(client, data) {
|
|
106
|
+
super(client, data);
|
|
107
|
+
this.url = data.url ?? null;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
Channel,
|
|
113
|
+
GuildChannel,
|
|
114
|
+
TextChannel,
|
|
115
|
+
CategoryChannel,
|
|
116
|
+
VoiceChannel,
|
|
117
|
+
LinkChannel
|
|
118
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
User
|
|
3
|
+
} from "./chunk-DLROMCIJ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Base
|
|
6
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
7
|
+
|
|
8
|
+
// src/structures/GuildMember.ts
|
|
9
|
+
import { Routes } from "@fluxerjs/types";
|
|
10
|
+
var GuildMember = class extends Base {
|
|
11
|
+
client;
|
|
12
|
+
id;
|
|
13
|
+
user;
|
|
14
|
+
guild;
|
|
15
|
+
nick;
|
|
16
|
+
roles;
|
|
17
|
+
joinedAt;
|
|
18
|
+
communicationDisabledUntil;
|
|
19
|
+
constructor(client, data, guild) {
|
|
20
|
+
super();
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.user = new User(client, data.user);
|
|
23
|
+
this.id = data.user.id;
|
|
24
|
+
this.guild = guild;
|
|
25
|
+
this.nick = data.nick ?? null;
|
|
26
|
+
this.roles = data.roles ?? [];
|
|
27
|
+
this.joinedAt = new Date(data.joined_at);
|
|
28
|
+
this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
|
|
29
|
+
}
|
|
30
|
+
/** Nickname, or global name, or username. */
|
|
31
|
+
get displayName() {
|
|
32
|
+
return this.nick ?? this.user.globalName ?? this.user.username;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Add a role to this member.
|
|
36
|
+
* @param roleId - The role ID to add
|
|
37
|
+
* Requires Manage Roles permission.
|
|
38
|
+
*/
|
|
39
|
+
async addRole(roleId) {
|
|
40
|
+
await this.client.rest.put(Routes.guildMemberRole(this.guild.id, this.id, roleId));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Remove a role from this member.
|
|
44
|
+
* @param roleId - The role ID to remove
|
|
45
|
+
* Requires Manage Roles permission.
|
|
46
|
+
*/
|
|
47
|
+
async removeRole(roleId) {
|
|
48
|
+
await this.client.rest.delete(Routes.guildMemberRole(this.guild.id, this.id, roleId));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
GuildMember
|
|
54
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
User
|
|
3
|
+
} from "./chunk-J3EIGOXQ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Base
|
|
6
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
7
|
+
|
|
8
|
+
// src/structures/GuildMember.ts
|
|
9
|
+
import { Routes } from "@fluxerjs/types";
|
|
10
|
+
var GuildMember = class extends Base {
|
|
11
|
+
client;
|
|
12
|
+
id;
|
|
13
|
+
user;
|
|
14
|
+
guild;
|
|
15
|
+
nick;
|
|
16
|
+
roles;
|
|
17
|
+
joinedAt;
|
|
18
|
+
communicationDisabledUntil;
|
|
19
|
+
/** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
|
|
20
|
+
constructor(client, data, guild) {
|
|
21
|
+
super();
|
|
22
|
+
this.client = client;
|
|
23
|
+
this.user = new User(client, data.user);
|
|
24
|
+
this.id = data.user.id;
|
|
25
|
+
this.guild = guild;
|
|
26
|
+
this.nick = data.nick ?? null;
|
|
27
|
+
this.roles = data.roles ?? [];
|
|
28
|
+
this.joinedAt = new Date(data.joined_at);
|
|
29
|
+
this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
|
|
30
|
+
}
|
|
31
|
+
/** Nickname, or global name, or username. */
|
|
32
|
+
get displayName() {
|
|
33
|
+
return this.nick ?? this.user.globalName ?? this.user.username;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Add a role to this member.
|
|
37
|
+
* @param roleId - The role ID to add
|
|
38
|
+
* Requires Manage Roles permission.
|
|
39
|
+
*/
|
|
40
|
+
async addRole(roleId) {
|
|
41
|
+
await this.client.rest.put(Routes.guildMemberRole(this.guild.id, this.id, roleId));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Remove a role from this member.
|
|
45
|
+
* @param roleId - The role ID to remove
|
|
46
|
+
* Requires Manage Roles permission.
|
|
47
|
+
*/
|
|
48
|
+
async removeRole(roleId) {
|
|
49
|
+
await this.client.rest.delete(Routes.guildMemberRole(this.guild.id, this.id, roleId));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
GuildMember
|
|
55
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
/** Create a DM channel from API data (type DM or GroupDM). */
|
|
9
|
+
static createDM(client, data) {
|
|
10
|
+
return new DMChannel(client, data);
|
|
11
|
+
}
|
|
12
|
+
client;
|
|
13
|
+
id;
|
|
14
|
+
type;
|
|
15
|
+
constructor(client, data) {
|
|
16
|
+
super();
|
|
17
|
+
this.client = client;
|
|
18
|
+
this.id = data.id;
|
|
19
|
+
this.type = data.type;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create the appropriate channel subclass from API data.
|
|
23
|
+
* @param client - The client instance
|
|
24
|
+
* @param data - Channel data from the API
|
|
25
|
+
*/
|
|
26
|
+
static from(client, data) {
|
|
27
|
+
const type = data.type ?? 0;
|
|
28
|
+
if (type === ChannelType.GuildText) return new TextChannel(client, data);
|
|
29
|
+
if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
30
|
+
if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
31
|
+
if (type === ChannelType.GuildLink) return new LinkChannel(client, data);
|
|
32
|
+
return new GuildChannel(client, data);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var GuildChannel = class extends Channel {
|
|
36
|
+
guildId;
|
|
37
|
+
name;
|
|
38
|
+
position;
|
|
39
|
+
parentId;
|
|
40
|
+
constructor(client, data) {
|
|
41
|
+
super(client, data);
|
|
42
|
+
this.guildId = data.guild_id ?? "";
|
|
43
|
+
this.name = data.name ?? null;
|
|
44
|
+
this.position = data.position;
|
|
45
|
+
this.parentId = data.parent_id ?? null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a webhook in this channel.
|
|
49
|
+
* @param options - Webhook name and optional avatar URL
|
|
50
|
+
* @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
|
|
51
|
+
*/
|
|
52
|
+
async createWebhook(options) {
|
|
53
|
+
const { Webhook } = await import("./Webhook-AG6QFM2I.mjs");
|
|
54
|
+
const data = await this.client.rest.post(Routes.channelWebhooks(this.id), {
|
|
55
|
+
body: options,
|
|
56
|
+
auth: true
|
|
57
|
+
});
|
|
58
|
+
return new Webhook(this.client, data);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fetch all webhooks in this channel.
|
|
62
|
+
* @returns Webhooks without token (cannot send). Requires Manage Webhooks permission.
|
|
63
|
+
*/
|
|
64
|
+
async fetchWebhooks() {
|
|
65
|
+
const { Webhook } = await import("./Webhook-AG6QFM2I.mjs");
|
|
66
|
+
const data = await this.client.rest.get(Routes.channelWebhooks(this.id));
|
|
67
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
68
|
+
return list.map((w) => new Webhook(this.client, w));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var TextChannel = class extends GuildChannel {
|
|
72
|
+
topic;
|
|
73
|
+
nsfw;
|
|
74
|
+
rateLimitPerUser;
|
|
75
|
+
lastMessageId;
|
|
76
|
+
constructor(client, data) {
|
|
77
|
+
super(client, data);
|
|
78
|
+
this.topic = data.topic ?? null;
|
|
79
|
+
this.nsfw = data.nsfw ?? false;
|
|
80
|
+
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
81
|
+
this.lastMessageId = data.last_message_id ?? null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Send a message to this channel.
|
|
85
|
+
* @param options - Text content or object with `content` and/or `embeds`
|
|
86
|
+
*/
|
|
87
|
+
async send(options) {
|
|
88
|
+
const body = typeof options === "string" ? { content: options } : options;
|
|
89
|
+
const { Message } = await import("./Message-ZCS7IGJX.mjs");
|
|
90
|
+
const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
|
|
91
|
+
return new Message(this.client, data);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var CategoryChannel = class extends GuildChannel {
|
|
95
|
+
};
|
|
96
|
+
var VoiceChannel = class extends GuildChannel {
|
|
97
|
+
bitrate;
|
|
98
|
+
userLimit;
|
|
99
|
+
rtcRegion;
|
|
100
|
+
constructor(client, data) {
|
|
101
|
+
super(client, data);
|
|
102
|
+
this.bitrate = data.bitrate ?? null;
|
|
103
|
+
this.userLimit = data.user_limit ?? null;
|
|
104
|
+
this.rtcRegion = data.rtc_region ?? null;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var LinkChannel = class extends GuildChannel {
|
|
108
|
+
url;
|
|
109
|
+
constructor(client, data) {
|
|
110
|
+
super(client, data);
|
|
111
|
+
this.url = data.url ?? null;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var DMChannel = class extends Channel {
|
|
115
|
+
lastMessageId;
|
|
116
|
+
constructor(client, data) {
|
|
117
|
+
super(client, data);
|
|
118
|
+
this.lastMessageId = data.last_message_id ?? null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Send a message to this DM channel.
|
|
122
|
+
* @param options - Text content or object with `content` and/or `embeds`
|
|
123
|
+
*/
|
|
124
|
+
async send(options) {
|
|
125
|
+
const body = typeof options === "string" ? { content: options } : options;
|
|
126
|
+
const { Message } = await import("./Message-ZCS7IGJX.mjs");
|
|
127
|
+
const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
|
|
128
|
+
return new Message(this.client, data);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
Channel,
|
|
134
|
+
GuildChannel,
|
|
135
|
+
TextChannel,
|
|
136
|
+
CategoryChannel,
|
|
137
|
+
VoiceChannel,
|
|
138
|
+
LinkChannel,
|
|
139
|
+
DMChannel
|
|
140
|
+
};
|
|
@@ -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-33APPS76.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
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
User
|
|
3
|
+
} from "./chunk-J3EIGOXQ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Base
|
|
6
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
7
|
+
|
|
8
|
+
// src/structures/Message.ts
|
|
9
|
+
import { Collection } from "@fluxerjs/collection";
|
|
10
|
+
import { Routes } from "@fluxerjs/types";
|
|
11
|
+
import { EmbedBuilder } from "@fluxerjs/builders";
|
|
12
|
+
var Message = class _Message extends Base {
|
|
13
|
+
client;
|
|
14
|
+
id;
|
|
15
|
+
channelId;
|
|
16
|
+
guildId;
|
|
17
|
+
author;
|
|
18
|
+
content;
|
|
19
|
+
createdAt;
|
|
20
|
+
editedAt;
|
|
21
|
+
pinned;
|
|
22
|
+
attachments;
|
|
23
|
+
channel;
|
|
24
|
+
/** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
|
|
25
|
+
constructor(client, data) {
|
|
26
|
+
super();
|
|
27
|
+
this.client = client;
|
|
28
|
+
this.id = data.id;
|
|
29
|
+
this.channelId = data.channel_id;
|
|
30
|
+
this.guildId = data.guild_id ?? null;
|
|
31
|
+
this.author = new User(client, data.author);
|
|
32
|
+
this.content = data.content;
|
|
33
|
+
this.createdAt = new Date(data.timestamp);
|
|
34
|
+
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
35
|
+
this.pinned = data.pinned;
|
|
36
|
+
this.attachments = new Collection();
|
|
37
|
+
for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Reply to this message.
|
|
41
|
+
* @param options - Text content or object with content and/or embeds
|
|
42
|
+
*/
|
|
43
|
+
async reply(options) {
|
|
44
|
+
const body = typeof options === "string" ? { content: options, message_reference: { channel_id: this.channelId, message_id: this.id, guild_id: this.guildId ?? void 0 } } : { ...options, message_reference: { channel_id: this.channelId, message_id: this.id, guild_id: this.guildId ?? void 0 } };
|
|
45
|
+
const data = await this.client.rest.post(Routes.channelMessages(this.channelId), { body });
|
|
46
|
+
return new _Message(this.client, data);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Edit this message. Only the author (or admins) can edit.
|
|
50
|
+
* @param options - New content and/or embeds
|
|
51
|
+
*/
|
|
52
|
+
async edit(options) {
|
|
53
|
+
const body = {};
|
|
54
|
+
if (options.content !== void 0) body.content = options.content;
|
|
55
|
+
if (options.embeds?.length) {
|
|
56
|
+
body.embeds = options.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
|
|
57
|
+
}
|
|
58
|
+
const data = await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), { body });
|
|
59
|
+
return new _Message(this.client, data);
|
|
60
|
+
}
|
|
61
|
+
/** Delete this message. */
|
|
62
|
+
async delete() {
|
|
63
|
+
await this.client.rest.delete(Routes.channelMessage(this.channelId, this.id));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Format emoji for reaction API: unicode string or "name:id" for custom.
|
|
67
|
+
* @param emoji - Unicode emoji (e.g. "👍") or custom { name, id } or "name:id" string
|
|
68
|
+
*/
|
|
69
|
+
static formatEmoji(emoji) {
|
|
70
|
+
if (typeof emoji === "string") return emoji;
|
|
71
|
+
return `${emoji.name}:${emoji.id}`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Add a reaction to this message (as the bot).
|
|
75
|
+
* @param emoji - Unicode emoji (e.g. `👍`) or custom emoji `{ name, id }`
|
|
76
|
+
*/
|
|
77
|
+
async react(emoji) {
|
|
78
|
+
const emojiStr = _Message.formatEmoji(emoji);
|
|
79
|
+
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/@me`;
|
|
80
|
+
await this.client.rest.put(route);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Remove the bot's reaction, or a specific user's reaction if userId is provided.
|
|
84
|
+
* @param emoji - Unicode emoji or custom `{ name, id }`
|
|
85
|
+
* @param userId - If provided, removes that user's reaction (requires moderator permissions)
|
|
86
|
+
*/
|
|
87
|
+
async removeReaction(emoji, userId) {
|
|
88
|
+
const emojiStr = _Message.formatEmoji(emoji);
|
|
89
|
+
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/${userId ?? "@me"}`;
|
|
90
|
+
await this.client.rest.delete(route);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Remove all reactions from this message.
|
|
94
|
+
* Requires moderator permissions.
|
|
95
|
+
*/
|
|
96
|
+
async removeAllReactions() {
|
|
97
|
+
await this.client.rest.delete(Routes.channelMessageReactions(this.channelId, this.id));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Remove all reactions of a specific emoji from this message.
|
|
101
|
+
* @param emoji - Unicode emoji or custom `{ name, id }`. Requires moderator permissions.
|
|
102
|
+
*/
|
|
103
|
+
async removeReactionEmoji(emoji) {
|
|
104
|
+
const emojiStr = _Message.formatEmoji(emoji);
|
|
105
|
+
await this.client.rest.delete(Routes.channelMessageReaction(this.channelId, this.id, emojiStr));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
Message
|
|
111
|
+
};
|