@fluxerjs/core 1.0.8 → 1.1.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/dist/{Channel-TWPDKW2P.mjs → Channel-WJZZSNML.mjs} +3 -1
- package/dist/{ClientUser-2K2BACK7.mjs → ClientUser-DJO2FS7P.mjs} +1 -1
- package/dist/Guild-2P77HBQM.mjs +11 -0
- package/dist/GuildBan-7CXLTPKY.mjs +7 -0
- package/dist/GuildMember-43B5E5CH.mjs +9 -0
- package/dist/{Message-G2QIKZQK.mjs → Invite-UM5BU5A6.mjs} +3 -3
- package/dist/Message-OFIVTTAZ.mjs +9 -0
- package/dist/{MessageReaction-XRPYZDSC.mjs → MessageReaction-V4UZ7OXE.mjs} +1 -1
- package/dist/{Role-SVLWIAMN.mjs → Role-5MWSGL66.mjs} +1 -1
- package/dist/Webhook-RWDDYW2Q.mjs +10 -0
- package/dist/chunk-4XJIM6SC.mjs +315 -0
- package/dist/chunk-AH7KYH2Z.mjs +50 -0
- package/dist/{chunk-HBF5QEDH.mjs → chunk-CEABHTAF.mjs} +1 -0
- package/dist/chunk-CJVQNARM.mjs +145 -0
- package/dist/chunk-DQ4TNBPG.mjs +63 -0
- package/dist/chunk-DUQAD7F6.mjs +173 -0
- package/dist/{chunk-4GCZFOS5.mjs → chunk-JHNKZIHY.mjs} +54 -3
- package/dist/chunk-LU2SNC5G.mjs +392 -0
- package/dist/chunk-PM2IUGNR.mjs +29 -0
- package/dist/chunk-QEXIYXXU.mjs +62 -0
- package/dist/chunk-UXIF75BV.mjs +36 -0
- package/dist/chunk-V7LPVPGH.mjs +305 -0
- package/dist/chunk-X6K3ZD62.mjs +53 -0
- package/dist/index.d.mts +802 -160
- package/dist/index.d.ts +802 -160
- package/dist/index.js +1467 -262
- package/dist/index.mjs +292 -119
- package/package.json +7 -7
- package/dist/Guild-CMZGA6DW.mjs +0 -10
- package/dist/GuildMember-DW2N6ITI.mjs +0 -7
- package/dist/Webhook-2MQESB7Z.mjs +0 -7
- package/dist/chunk-CO5EL5LH.mjs +0 -168
- package/dist/chunk-CZIO2D7F.mjs +0 -207
- package/dist/chunk-JVEOQFUX.mjs +0 -52
- package/dist/chunk-SQVCCSNN.mjs +0 -41
- package/dist/chunk-TJVZEILY.mjs +0 -120
- package/dist/chunk-ZGMM6IPQ.mjs +0 -79
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.0
|
|
6
|
+
"version": "1.1.0",
|
|
7
7
|
"description": "A fully-featured SDK for Fluxer bots",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@fluxerjs/
|
|
38
|
-
"@fluxerjs/
|
|
39
|
-
"@fluxerjs/
|
|
40
|
-
"@fluxerjs/
|
|
41
|
-
"@fluxerjs/
|
|
42
|
-
"@fluxerjs/
|
|
37
|
+
"@fluxerjs/ws": "1.1.0",
|
|
38
|
+
"@fluxerjs/collection": "1.1.0",
|
|
39
|
+
"@fluxerjs/rest": "1.1.0",
|
|
40
|
+
"@fluxerjs/builders": "1.1.0",
|
|
41
|
+
"@fluxerjs/util": "1.1.0",
|
|
42
|
+
"@fluxerjs/types": "1.1.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^20.0.0",
|
package/dist/Guild-CMZGA6DW.mjs
DELETED
package/dist/chunk-CO5EL5LH.mjs
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Base
|
|
3
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/structures/Message.ts
|
|
6
|
-
import { Collection } from "@fluxerjs/collection";
|
|
7
|
-
import { Routes } from "@fluxerjs/types";
|
|
8
|
-
import { EmbedBuilder } from "@fluxerjs/builders";
|
|
9
|
-
var Message = class _Message extends Base {
|
|
10
|
-
client;
|
|
11
|
-
id;
|
|
12
|
-
channelId;
|
|
13
|
-
guildId;
|
|
14
|
-
author;
|
|
15
|
-
content;
|
|
16
|
-
createdAt;
|
|
17
|
-
editedAt;
|
|
18
|
-
pinned;
|
|
19
|
-
attachments;
|
|
20
|
-
/** Channel where this message was sent. Resolved from cache; null if not cached (e.g. DM channel not in cache). */
|
|
21
|
-
get channel() {
|
|
22
|
-
return this.client.channels.get(this.channelId) ?? null;
|
|
23
|
-
}
|
|
24
|
-
/** Guild where this message was sent. Resolved from cache; null for DMs or if not cached. */
|
|
25
|
-
get guild() {
|
|
26
|
-
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
27
|
-
}
|
|
28
|
-
/** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
|
|
29
|
-
constructor(client, data) {
|
|
30
|
-
super();
|
|
31
|
-
this.client = client;
|
|
32
|
-
this.id = data.id;
|
|
33
|
-
this.channelId = data.channel_id;
|
|
34
|
-
this.guildId = data.guild_id ?? null;
|
|
35
|
-
this.author = client.getOrCreateUser(data.author);
|
|
36
|
-
this.content = data.content;
|
|
37
|
-
this.createdAt = new Date(data.timestamp);
|
|
38
|
-
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
39
|
-
this.pinned = data.pinned;
|
|
40
|
-
this.attachments = new Collection();
|
|
41
|
-
for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Send a message to this channel without replying. Use when you want a standalone message.
|
|
45
|
-
* @param options - Text content or object with content and/or embeds
|
|
46
|
-
* @example
|
|
47
|
-
* await message.send('Pong!');
|
|
48
|
-
* await message.send({ embeds: [embed.toJSON()] });
|
|
49
|
-
*/
|
|
50
|
-
async send(options) {
|
|
51
|
-
const body = typeof options === "string" ? { content: options } : options;
|
|
52
|
-
const data = await this.client.rest.post(Routes.channelMessages(this.channelId), { body });
|
|
53
|
-
return new _Message(this.client, data);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Send a message to a specific channel. Use for logging, forwarding, or sending to another channel in the guild.
|
|
57
|
-
* @param channelId - Snowflake of the target channel (e.g. log channel ID)
|
|
58
|
-
* @param options - Text content or object with content and/or embeds
|
|
59
|
-
* @example
|
|
60
|
-
* await message.sendTo(logChannelId, 'User ' + message.author.username + ' said: ' + message.content);
|
|
61
|
-
* await message.sendTo(announceChannelId, { embeds: [embed.toJSON()] });
|
|
62
|
-
*/
|
|
63
|
-
async sendTo(channelId, options) {
|
|
64
|
-
return this.client.channels.send(channelId, options);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Reply to this message.
|
|
68
|
-
* @param options - Text content or object with content and/or embeds
|
|
69
|
-
*/
|
|
70
|
-
async reply(options) {
|
|
71
|
-
const body = typeof options === "string" ? {
|
|
72
|
-
content: options,
|
|
73
|
-
message_reference: {
|
|
74
|
-
channel_id: this.channelId,
|
|
75
|
-
message_id: this.id,
|
|
76
|
-
guild_id: this.guildId ?? void 0
|
|
77
|
-
}
|
|
78
|
-
} : {
|
|
79
|
-
...options,
|
|
80
|
-
message_reference: {
|
|
81
|
-
channel_id: this.channelId,
|
|
82
|
-
message_id: this.id,
|
|
83
|
-
guild_id: this.guildId ?? void 0
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const data = await this.client.rest.post(Routes.channelMessages(this.channelId), { body });
|
|
87
|
-
return new _Message(this.client, data);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Edit this message. Only the author (or admins) can edit.
|
|
91
|
-
* @param options - New content and/or embeds
|
|
92
|
-
*/
|
|
93
|
-
async edit(options) {
|
|
94
|
-
const body = {};
|
|
95
|
-
if (options.content !== void 0) body.content = options.content;
|
|
96
|
-
if (options.embeds?.length) {
|
|
97
|
-
body.embeds = options.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
|
|
98
|
-
}
|
|
99
|
-
const data = await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), {
|
|
100
|
-
body
|
|
101
|
-
});
|
|
102
|
-
return new _Message(this.client, data);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Re-fetch this message from the API to get the latest content, embeds, reactions, etc.
|
|
106
|
-
* Use when you have a stale Message (e.g. from an old event or cache) and need fresh data.
|
|
107
|
-
* @returns The updated message, or null if deleted or not found
|
|
108
|
-
* @example
|
|
109
|
-
* const updated = await message.fetch();
|
|
110
|
-
* if (updated) console.log('Latest content:', updated.content);
|
|
111
|
-
*/
|
|
112
|
-
async fetch() {
|
|
113
|
-
return this.client.channels.fetchMessage(this.channelId, this.id);
|
|
114
|
-
}
|
|
115
|
-
/** Delete this message. */
|
|
116
|
-
async delete() {
|
|
117
|
-
await this.client.rest.delete(Routes.channelMessage(this.channelId, this.id));
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Format emoji for reaction API: unicode string or "name:id" for custom.
|
|
121
|
-
* For string resolution (e.g. :name:), use client.resolveEmoji; Message methods resolve automatically when guildId is available.
|
|
122
|
-
*/
|
|
123
|
-
static formatEmoji(emoji) {
|
|
124
|
-
if (typeof emoji === "string") return emoji;
|
|
125
|
-
return `${emoji.name}:${emoji.id}`;
|
|
126
|
-
}
|
|
127
|
-
resolveEmojiForReaction(emoji) {
|
|
128
|
-
return this.client.resolveEmoji(emoji, this.guildId);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Add a reaction to this message (as the bot).
|
|
132
|
-
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
|
|
133
|
-
*/
|
|
134
|
-
async react(emoji) {
|
|
135
|
-
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
136
|
-
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/@me`;
|
|
137
|
-
await this.client.rest.put(route);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Remove the bot's reaction, or a specific user's reaction if userId is provided.
|
|
141
|
-
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
|
|
142
|
-
* @param userId - If provided, removes that user's reaction (requires moderator permissions)
|
|
143
|
-
*/
|
|
144
|
-
async removeReaction(emoji, userId) {
|
|
145
|
-
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
146
|
-
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/${userId ?? "@me"}`;
|
|
147
|
-
await this.client.rest.delete(route);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Remove all reactions from this message.
|
|
151
|
-
* Requires moderator permissions.
|
|
152
|
-
*/
|
|
153
|
-
async removeAllReactions() {
|
|
154
|
-
await this.client.rest.delete(Routes.channelMessageReactions(this.channelId, this.id));
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Remove all reactions of a specific emoji from this message.
|
|
158
|
-
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`. Requires moderator permissions.
|
|
159
|
-
*/
|
|
160
|
-
async removeReactionEmoji(emoji) {
|
|
161
|
-
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
162
|
-
await this.client.rest.delete(Routes.channelMessageReaction(this.channelId, this.id, emojiStr));
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export {
|
|
167
|
-
Message
|
|
168
|
-
};
|
package/dist/chunk-CZIO2D7F.mjs
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Base
|
|
3
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/client/MessageManager.ts
|
|
6
|
-
var MessageManager = class {
|
|
7
|
-
constructor(client, channelId) {
|
|
8
|
-
this.client = client;
|
|
9
|
-
this.channelId = channelId;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Fetch a message by ID from this channel.
|
|
13
|
-
* @param messageId - Snowflake of the message
|
|
14
|
-
* @returns The message, or null if not found
|
|
15
|
-
*/
|
|
16
|
-
async fetch(messageId) {
|
|
17
|
-
return this.client.channels.fetchMessage(this.channelId, messageId);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// src/structures/Channel.ts
|
|
22
|
-
import { ChannelType, Routes } from "@fluxerjs/types";
|
|
23
|
-
var Channel = class _Channel extends Base {
|
|
24
|
-
/** Whether this channel has a send method (TextChannel, DMChannel). */
|
|
25
|
-
isSendable() {
|
|
26
|
-
return "send" in this;
|
|
27
|
-
}
|
|
28
|
-
/** Whether this channel is a DM or Group DM. */
|
|
29
|
-
isDM() {
|
|
30
|
-
return this.type === ChannelType.DM || this.type === ChannelType.GroupDM;
|
|
31
|
-
}
|
|
32
|
-
/** Whether this channel is voice-based (VoiceChannel). */
|
|
33
|
-
isVoice() {
|
|
34
|
-
return "bitrate" in this;
|
|
35
|
-
}
|
|
36
|
-
/** Create a DM channel from API data (type DM or GroupDM). */
|
|
37
|
-
static createDM(client, data) {
|
|
38
|
-
return new DMChannel(client, data);
|
|
39
|
-
}
|
|
40
|
-
client;
|
|
41
|
-
id;
|
|
42
|
-
type;
|
|
43
|
-
/** @param data - API channel from GET /channels/{id} or GET /guilds/{id}/channels */
|
|
44
|
-
constructor(client, data) {
|
|
45
|
-
super();
|
|
46
|
-
this.client = client;
|
|
47
|
-
this.id = data.id;
|
|
48
|
-
this.type = data.type;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Create the appropriate channel subclass from API data.
|
|
52
|
-
* @param client - The client instance
|
|
53
|
-
* @param data - Channel data from the API
|
|
54
|
-
*/
|
|
55
|
-
static from(client, data) {
|
|
56
|
-
const type = data.type ?? 0;
|
|
57
|
-
if (type === ChannelType.GuildText) return new TextChannel(client, data);
|
|
58
|
-
if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
59
|
-
if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
60
|
-
if (type === ChannelType.GuildLink || type === ChannelType.GuildLinkExtended)
|
|
61
|
-
return new LinkChannel(client, data);
|
|
62
|
-
return new GuildChannel(client, data);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Create a channel from API data, including DM and GroupDM.
|
|
66
|
-
* Used by ChannelManager.fetch() for GET /channels/{id}.
|
|
67
|
-
*/
|
|
68
|
-
static fromOrCreate(client, data) {
|
|
69
|
-
const type = data.type ?? 0;
|
|
70
|
-
if (type === ChannelType.DM || type === ChannelType.GroupDM)
|
|
71
|
-
return _Channel.createDM(client, data);
|
|
72
|
-
return _Channel.from(client, data);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
var GuildChannel = class extends Channel {
|
|
76
|
-
guildId;
|
|
77
|
-
name;
|
|
78
|
-
position;
|
|
79
|
-
parentId;
|
|
80
|
-
constructor(client, data) {
|
|
81
|
-
super(client, data);
|
|
82
|
-
this.guildId = data.guild_id ?? "";
|
|
83
|
-
this.name = data.name ?? null;
|
|
84
|
-
this.position = data.position;
|
|
85
|
-
this.parentId = data.parent_id ?? null;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Create a webhook in this channel.
|
|
89
|
-
* @param options - Webhook name and optional avatar URL
|
|
90
|
-
* @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
|
|
91
|
-
*/
|
|
92
|
-
async createWebhook(options) {
|
|
93
|
-
const { Webhook } = await import("./Webhook-2MQESB7Z.mjs");
|
|
94
|
-
const data = await this.client.rest.post(Routes.channelWebhooks(this.id), {
|
|
95
|
-
body: options,
|
|
96
|
-
auth: true
|
|
97
|
-
});
|
|
98
|
-
return new Webhook(this.client, data);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Fetch all webhooks in this channel.
|
|
102
|
-
* @returns Webhooks (includes token when listing from channel; can send via send())
|
|
103
|
-
*/
|
|
104
|
-
async fetchWebhooks() {
|
|
105
|
-
const { Webhook } = await import("./Webhook-2MQESB7Z.mjs");
|
|
106
|
-
const data = await this.client.rest.get(Routes.channelWebhooks(this.id));
|
|
107
|
-
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
108
|
-
return list.map((w) => new Webhook(this.client, w));
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
var TextChannel = class extends GuildChannel {
|
|
112
|
-
topic;
|
|
113
|
-
nsfw;
|
|
114
|
-
rateLimitPerUser;
|
|
115
|
-
lastMessageId;
|
|
116
|
-
constructor(client, data) {
|
|
117
|
-
super(client, data);
|
|
118
|
-
this.topic = data.topic ?? null;
|
|
119
|
-
this.nsfw = data.nsfw ?? false;
|
|
120
|
-
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
121
|
-
this.lastMessageId = data.last_message_id ?? null;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Send a message to this channel.
|
|
125
|
-
* @param options - Text content or object with `content` and/or `embeds`
|
|
126
|
-
*/
|
|
127
|
-
async send(options) {
|
|
128
|
-
const body = typeof options === "string" ? { content: options } : options;
|
|
129
|
-
const { Message } = await import("./Message-G2QIKZQK.mjs");
|
|
130
|
-
const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
|
|
131
|
-
return new Message(this.client, data);
|
|
132
|
-
}
|
|
133
|
-
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
134
|
-
get messages() {
|
|
135
|
-
return new MessageManager(this.client, this.id);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Fetch a message by ID from this channel.
|
|
139
|
-
* @param messageId - Snowflake of the message
|
|
140
|
-
* @returns The message, or null if not found
|
|
141
|
-
* @deprecated Use channel.messages.fetch(messageId) instead.
|
|
142
|
-
*/
|
|
143
|
-
async fetchMessage(messageId) {
|
|
144
|
-
return this.client.channels.fetchMessage(this.id, messageId);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
var CategoryChannel = class extends GuildChannel {
|
|
148
|
-
};
|
|
149
|
-
var VoiceChannel = class extends GuildChannel {
|
|
150
|
-
bitrate;
|
|
151
|
-
userLimit;
|
|
152
|
-
rtcRegion;
|
|
153
|
-
constructor(client, data) {
|
|
154
|
-
super(client, data);
|
|
155
|
-
this.bitrate = data.bitrate ?? null;
|
|
156
|
-
this.userLimit = data.user_limit ?? null;
|
|
157
|
-
this.rtcRegion = data.rtc_region ?? null;
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
var LinkChannel = class extends GuildChannel {
|
|
161
|
-
url;
|
|
162
|
-
constructor(client, data) {
|
|
163
|
-
super(client, data);
|
|
164
|
-
this.url = data.url ?? null;
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
var DMChannel = class extends Channel {
|
|
168
|
-
lastMessageId;
|
|
169
|
-
constructor(client, data) {
|
|
170
|
-
super(client, data);
|
|
171
|
-
this.lastMessageId = data.last_message_id ?? null;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Send a message to this DM channel.
|
|
175
|
-
* @param options - Text content or object with `content` and/or `embeds`
|
|
176
|
-
*/
|
|
177
|
-
async send(options) {
|
|
178
|
-
const body = typeof options === "string" ? { content: options } : options;
|
|
179
|
-
const { Message } = await import("./Message-G2QIKZQK.mjs");
|
|
180
|
-
const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
|
|
181
|
-
return new Message(this.client, data);
|
|
182
|
-
}
|
|
183
|
-
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
184
|
-
get messages() {
|
|
185
|
-
return new MessageManager(this.client, this.id);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Fetch a message by ID from this DM channel.
|
|
189
|
-
* @param messageId - Snowflake of the message
|
|
190
|
-
* @returns The message, or null if not found
|
|
191
|
-
* @deprecated Use channel.messages.fetch(messageId) instead.
|
|
192
|
-
*/
|
|
193
|
-
async fetchMessage(messageId) {
|
|
194
|
-
return this.client.channels.fetchMessage(this.id, messageId);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export {
|
|
199
|
-
MessageManager,
|
|
200
|
-
Channel,
|
|
201
|
-
GuildChannel,
|
|
202
|
-
TextChannel,
|
|
203
|
-
CategoryChannel,
|
|
204
|
-
VoiceChannel,
|
|
205
|
-
LinkChannel,
|
|
206
|
-
DMChannel
|
|
207
|
-
};
|
package/dist/chunk-JVEOQFUX.mjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Base
|
|
3
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/structures/GuildMember.ts
|
|
6
|
-
import { Routes } from "@fluxerjs/types";
|
|
7
|
-
var GuildMember = class extends Base {
|
|
8
|
-
client;
|
|
9
|
-
id;
|
|
10
|
-
user;
|
|
11
|
-
guild;
|
|
12
|
-
nick;
|
|
13
|
-
roles;
|
|
14
|
-
joinedAt;
|
|
15
|
-
communicationDisabledUntil;
|
|
16
|
-
/** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
|
|
17
|
-
constructor(client, data, guild) {
|
|
18
|
-
super();
|
|
19
|
-
this.client = client;
|
|
20
|
-
this.user = client.getOrCreateUser(data.user);
|
|
21
|
-
this.id = data.user.id;
|
|
22
|
-
this.guild = guild;
|
|
23
|
-
this.nick = data.nick ?? null;
|
|
24
|
-
this.roles = data.roles ?? [];
|
|
25
|
-
this.joinedAt = new Date(data.joined_at);
|
|
26
|
-
this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
|
|
27
|
-
}
|
|
28
|
-
/** Nickname, or global name, or username. */
|
|
29
|
-
get displayName() {
|
|
30
|
-
return this.nick ?? this.user.globalName ?? this.user.username;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Add a role to this member.
|
|
34
|
-
* @param roleId - The role ID to add
|
|
35
|
-
* Requires Manage Roles permission.
|
|
36
|
-
*/
|
|
37
|
-
async addRole(roleId) {
|
|
38
|
-
await this.client.rest.put(Routes.guildMemberRole(this.guild.id, this.id, roleId));
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Remove a role from this member.
|
|
42
|
-
* @param roleId - The role ID to remove
|
|
43
|
-
* Requires Manage Roles permission.
|
|
44
|
-
*/
|
|
45
|
-
async removeRole(roleId) {
|
|
46
|
-
await this.client.rest.delete(Routes.guildMemberRole(this.guild.id, this.id, roleId));
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
GuildMember
|
|
52
|
-
};
|
package/dist/chunk-SQVCCSNN.mjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Base
|
|
3
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/structures/Role.ts
|
|
6
|
-
var Role = class extends Base {
|
|
7
|
-
client;
|
|
8
|
-
id;
|
|
9
|
-
guildId;
|
|
10
|
-
name;
|
|
11
|
-
color;
|
|
12
|
-
position;
|
|
13
|
-
permissions;
|
|
14
|
-
hoist;
|
|
15
|
-
mentionable;
|
|
16
|
-
unicodeEmoji;
|
|
17
|
-
/** @param client - The client instance */
|
|
18
|
-
/** @param data - API role from GET /guilds/{id}/roles or gateway role events */
|
|
19
|
-
/** @param guildId - The guild this role belongs to */
|
|
20
|
-
constructor(client, data, guildId) {
|
|
21
|
-
super();
|
|
22
|
-
this.client = client;
|
|
23
|
-
this.id = data.id;
|
|
24
|
-
this.guildId = guildId;
|
|
25
|
-
this.name = data.name;
|
|
26
|
-
this.color = data.color;
|
|
27
|
-
this.position = data.position;
|
|
28
|
-
this.permissions = data.permissions;
|
|
29
|
-
this.hoist = !!data.hoist;
|
|
30
|
-
this.mentionable = !!data.mentionable;
|
|
31
|
-
this.unicodeEmoji = data.unicode_emoji ?? null;
|
|
32
|
-
}
|
|
33
|
-
/** Returns a mention string (e.g. `<@&123456>`). */
|
|
34
|
-
toString() {
|
|
35
|
-
return `<@&${this.id}>`;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
Role
|
|
41
|
-
};
|
package/dist/chunk-TJVZEILY.mjs
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CDN_URL
|
|
3
|
-
} from "./chunk-HQMYRYMY.mjs";
|
|
4
|
-
import {
|
|
5
|
-
GuildMember
|
|
6
|
-
} from "./chunk-JVEOQFUX.mjs";
|
|
7
|
-
import {
|
|
8
|
-
Role
|
|
9
|
-
} from "./chunk-SQVCCSNN.mjs";
|
|
10
|
-
import {
|
|
11
|
-
Base
|
|
12
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
13
|
-
|
|
14
|
-
// src/structures/Guild.ts
|
|
15
|
-
import { parseRoleMention } from "@fluxerjs/util";
|
|
16
|
-
import { Collection } from "@fluxerjs/collection";
|
|
17
|
-
import { Routes } from "@fluxerjs/types";
|
|
18
|
-
var Guild = class extends Base {
|
|
19
|
-
client;
|
|
20
|
-
id;
|
|
21
|
-
name;
|
|
22
|
-
icon;
|
|
23
|
-
banner;
|
|
24
|
-
ownerId;
|
|
25
|
-
members = new Collection();
|
|
26
|
-
channels = new Collection();
|
|
27
|
-
roles = new Collection();
|
|
28
|
-
/** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
|
|
29
|
-
constructor(client, data) {
|
|
30
|
-
super();
|
|
31
|
-
this.client = client;
|
|
32
|
-
this.id = data.id;
|
|
33
|
-
this.name = data.name;
|
|
34
|
-
this.icon = data.icon ?? null;
|
|
35
|
-
this.banner = data.banner ?? null;
|
|
36
|
-
this.ownerId = data.owner_id;
|
|
37
|
-
for (const r of data.roles ?? []) {
|
|
38
|
-
this.roles.set(r.id, new Role(client, r, this.id));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/** Get the guild icon URL, or null if no icon. */
|
|
42
|
-
iconURL(options) {
|
|
43
|
-
if (!this.icon) return null;
|
|
44
|
-
const size = options?.size ? `?size=${options.size}` : "";
|
|
45
|
-
return `${CDN_URL}/icons/${this.id}/${this.icon}.png${size}`;
|
|
46
|
-
}
|
|
47
|
-
/** Get the guild banner URL, or null if no banner. */
|
|
48
|
-
bannerURL(options) {
|
|
49
|
-
if (!this.banner) return null;
|
|
50
|
-
const size = options?.size ? `?size=${options.size}` : "";
|
|
51
|
-
return `${CDN_URL}/banners/${this.id}/${this.banner}.png${size}`;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Add a role to a member by user ID. Does not require fetching the member first.
|
|
55
|
-
* @param userId - The user ID of the member
|
|
56
|
-
* @param roleId - The role ID to add (or use guild.resolveRoleId for mention/name resolution)
|
|
57
|
-
* Requires Manage Roles permission.
|
|
58
|
-
*/
|
|
59
|
-
async addRoleToMember(userId, roleId) {
|
|
60
|
-
await this.client.rest.put(Routes.guildMemberRole(this.id, userId, roleId));
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Remove a role from a member by user ID. Does not require fetching the member first.
|
|
64
|
-
* @param userId - The user ID of the member
|
|
65
|
-
* @param roleId - The role ID to remove
|
|
66
|
-
* Requires Manage Roles permission.
|
|
67
|
-
*/
|
|
68
|
-
async removeRoleFromMember(userId, roleId) {
|
|
69
|
-
await this.client.rest.delete(Routes.guildMemberRole(this.id, userId, roleId));
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Resolve a role ID from an argument (role mention, raw ID, or name).
|
|
73
|
-
* Fetches guild roles if name is provided.
|
|
74
|
-
* @param arg - Role mention (@role), role ID, or role name
|
|
75
|
-
* @returns The role ID, or null if not found
|
|
76
|
-
*/
|
|
77
|
-
async resolveRoleId(arg) {
|
|
78
|
-
const parsed = parseRoleMention(arg);
|
|
79
|
-
if (parsed) return parsed;
|
|
80
|
-
if (/^\d{17,19}$/.test(arg.trim())) return arg.trim();
|
|
81
|
-
const cached = this.roles.find(
|
|
82
|
-
(r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
|
|
83
|
-
);
|
|
84
|
-
if (cached) return cached.id;
|
|
85
|
-
const roles = await this.client.rest.get(Routes.guildRoles(this.id));
|
|
86
|
-
const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
|
|
87
|
-
const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
|
|
88
|
-
if (role) {
|
|
89
|
-
this.roles.set(role.id, new Role(this.client, role, this.id));
|
|
90
|
-
return role.id;
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Fetch a guild member by user ID.
|
|
96
|
-
* @param userId - The user ID of the member to fetch
|
|
97
|
-
* @returns The guild member, or null if not found
|
|
98
|
-
*/
|
|
99
|
-
async fetchMember(userId) {
|
|
100
|
-
try {
|
|
101
|
-
const data = await this.client.rest.get(
|
|
102
|
-
Routes.guildMember(this.id, userId)
|
|
103
|
-
);
|
|
104
|
-
return new GuildMember(this.client, { ...data, guild_id: this.id }, this);
|
|
105
|
-
} catch {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
110
|
-
async fetchWebhooks() {
|
|
111
|
-
const { Webhook } = await import("./Webhook-2MQESB7Z.mjs");
|
|
112
|
-
const data = await this.client.rest.get(Routes.guildWebhooks(this.id));
|
|
113
|
-
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
114
|
-
return list.map((w) => new Webhook(this.client, w));
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export {
|
|
119
|
-
Guild
|
|
120
|
-
};
|