@fluxerjs/core 1.0.4 → 1.0.6
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-IKL3SJXN.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-33APPS76.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-3CNUPFDI.mjs +59 -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-OHIHIQAS.mjs +102 -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 +74 -6
- package/dist/index.d.ts +74 -6
- package/dist/index.js +145 -21
- package/dist/index.mjs +34 -13
- 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-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,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
User
|
|
3
|
+
} from "./chunk-SW6KNICI.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Base
|
|
6
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
7
|
+
|
|
8
|
+
// src/structures/GuildMember.ts
|
|
9
|
+
var GuildMember = class extends Base {
|
|
10
|
+
client;
|
|
11
|
+
id;
|
|
12
|
+
user;
|
|
13
|
+
guild;
|
|
14
|
+
nick;
|
|
15
|
+
roles;
|
|
16
|
+
joinedAt;
|
|
17
|
+
communicationDisabledUntil;
|
|
18
|
+
constructor(client, data, guild) {
|
|
19
|
+
super();
|
|
20
|
+
this.client = client;
|
|
21
|
+
this.user = new User(client, data.user);
|
|
22
|
+
this.id = data.user.id;
|
|
23
|
+
this.guild = guild;
|
|
24
|
+
this.nick = data.nick ?? null;
|
|
25
|
+
this.roles = data.roles ?? [];
|
|
26
|
+
this.joinedAt = new Date(data.joined_at);
|
|
27
|
+
this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
|
|
28
|
+
}
|
|
29
|
+
get displayName() {
|
|
30
|
+
return this.nick ?? this.user.globalName ?? this.user.username;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
GuildMember
|
|
36
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Base
|
|
3
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/structures/Webhook.ts
|
|
6
|
+
import { Routes } from "@fluxerjs/types";
|
|
7
|
+
var Webhook = class _Webhook extends Base {
|
|
8
|
+
client;
|
|
9
|
+
id;
|
|
10
|
+
guildId;
|
|
11
|
+
channelId;
|
|
12
|
+
name;
|
|
13
|
+
avatar;
|
|
14
|
+
/** Present only when webhook was created via createWebhook(); not returned when fetching. */
|
|
15
|
+
token;
|
|
16
|
+
constructor(client, data) {
|
|
17
|
+
super();
|
|
18
|
+
this.client = client;
|
|
19
|
+
this.id = data.id;
|
|
20
|
+
this.guildId = data.guild_id;
|
|
21
|
+
this.channelId = data.channel_id;
|
|
22
|
+
this.name = data.name ?? "Unknown";
|
|
23
|
+
this.avatar = data.avatar ?? null;
|
|
24
|
+
this.token = data.token ?? null;
|
|
25
|
+
}
|
|
26
|
+
/** Delete this webhook. Requires bot token with Manage Webhooks permission. */
|
|
27
|
+
async delete() {
|
|
28
|
+
await this.client.rest.delete(Routes.webhook(this.id), { auth: true });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
|
|
32
|
+
* @throws Error if token is not available
|
|
33
|
+
*/
|
|
34
|
+
async send(options) {
|
|
35
|
+
if (!this.token) {
|
|
36
|
+
throw new Error("Webhook token is required to send. The token is only returned when creating a webhook; fetched webhooks cannot send.");
|
|
37
|
+
}
|
|
38
|
+
const body = typeof options === "string" ? { content: options } : options;
|
|
39
|
+
await this.client.rest.post(Routes.webhookExecute(this.id, this.token), {
|
|
40
|
+
body,
|
|
41
|
+
auth: false
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fetch a webhook by ID using bot auth. The returned webhook will not have a token (cannot send).
|
|
46
|
+
*/
|
|
47
|
+
static async fetch(client, webhookId) {
|
|
48
|
+
const data = await client.rest.get(Routes.webhook(webhookId));
|
|
49
|
+
return new _Webhook(client, data);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
|
|
53
|
+
* Useful when you have the token from a previous createWebhook() call.
|
|
54
|
+
*/
|
|
55
|
+
static fromToken(client, webhookId, token, options) {
|
|
56
|
+
return new _Webhook(client, {
|
|
57
|
+
id: webhookId,
|
|
58
|
+
guild_id: options?.guildId ?? "",
|
|
59
|
+
channel_id: options?.channelId ?? "",
|
|
60
|
+
name: options?.name ?? "Webhook",
|
|
61
|
+
avatar: null,
|
|
62
|
+
token,
|
|
63
|
+
user: { id: "", username: "webhook" }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
Webhook
|
|
70
|
+
};
|
|
@@ -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,11 +1,12 @@
|
|
|
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
|
+
import { EmbedBuilder } from '@fluxerjs/builders';
|
|
6
|
+
export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
|
|
5
7
|
import { EventEmitter } from 'events';
|
|
6
8
|
import { REST } from '@fluxerjs/rest';
|
|
7
9
|
import { WebSocketManager } from '@fluxerjs/ws';
|
|
8
|
-
export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
|
|
9
10
|
|
|
10
11
|
declare abstract class Base {
|
|
11
12
|
abstract readonly client: Client;
|
|
@@ -30,6 +31,11 @@ declare class User extends Base {
|
|
|
30
31
|
toString(): string;
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
/** Options for editing a message (content and/or embeds). */
|
|
35
|
+
interface MessageEditOptions {
|
|
36
|
+
content?: string;
|
|
37
|
+
embeds?: (APIEmbed | EmbedBuilder)[];
|
|
38
|
+
}
|
|
33
39
|
declare class Message extends Base {
|
|
34
40
|
readonly client: Client;
|
|
35
41
|
readonly id: string;
|
|
@@ -47,10 +53,53 @@ declare class Message extends Base {
|
|
|
47
53
|
content?: string;
|
|
48
54
|
embeds?: APIEmbed[];
|
|
49
55
|
}): Promise<Message>;
|
|
50
|
-
edit(options:
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
edit(options: MessageEditOptions): Promise<Message>;
|
|
57
|
+
delete(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface WebhookSendOptions {
|
|
61
|
+
content?: string;
|
|
62
|
+
embeds?: Array<Record<string, unknown>>;
|
|
63
|
+
username?: string;
|
|
64
|
+
avatar_url?: string;
|
|
65
|
+
tts?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Represents a Discord/Fluxer webhook. Supports creating, fetching, sending, and deleting.
|
|
69
|
+
* The token is only available when the webhook was created; fetched webhooks cannot send messages.
|
|
70
|
+
*/
|
|
71
|
+
declare class Webhook extends Base {
|
|
72
|
+
readonly client: Client;
|
|
73
|
+
readonly id: string;
|
|
74
|
+
readonly guildId: string;
|
|
75
|
+
readonly channelId: string;
|
|
76
|
+
name: string;
|
|
77
|
+
avatar: string | null;
|
|
78
|
+
/** Present only when webhook was created via createWebhook(); not returned when fetching. */
|
|
79
|
+
readonly token: string | null;
|
|
80
|
+
constructor(client: Client, data: APIWebhook & {
|
|
81
|
+
token?: string | null;
|
|
82
|
+
});
|
|
83
|
+
/** Delete this webhook. Requires bot token with Manage Webhooks permission. */
|
|
53
84
|
delete(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
|
|
87
|
+
* @throws Error if token is not available
|
|
88
|
+
*/
|
|
89
|
+
send(options: string | WebhookSendOptions): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Fetch a webhook by ID using bot auth. The returned webhook will not have a token (cannot send).
|
|
92
|
+
*/
|
|
93
|
+
static fetch(client: Client, webhookId: string): Promise<Webhook>;
|
|
94
|
+
/**
|
|
95
|
+
* Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
|
|
96
|
+
* Useful when you have the token from a previous createWebhook() call.
|
|
97
|
+
*/
|
|
98
|
+
static fromToken(client: Client, webhookId: string, token: string, options?: {
|
|
99
|
+
channelId?: string;
|
|
100
|
+
guildId?: string;
|
|
101
|
+
name?: string;
|
|
102
|
+
}): Webhook;
|
|
54
103
|
}
|
|
55
104
|
|
|
56
105
|
declare abstract class Channel extends Base {
|
|
@@ -66,6 +115,13 @@ declare class GuildChannel extends Channel {
|
|
|
66
115
|
position?: number;
|
|
67
116
|
parentId: string | null;
|
|
68
117
|
constructor(client: Client, data: APIChannel);
|
|
118
|
+
/** Create a webhook in this channel. Returns the webhook with token (required for send()). */
|
|
119
|
+
createWebhook(options: {
|
|
120
|
+
name: string;
|
|
121
|
+
avatar?: string | null;
|
|
122
|
+
}): Promise<Webhook>;
|
|
123
|
+
/** Fetch all webhooks in this channel. Returned webhooks do not include the token (cannot send). */
|
|
124
|
+
fetchWebhooks(): Promise<Webhook[]>;
|
|
69
125
|
}
|
|
70
126
|
declare class TextChannel extends GuildChannel {
|
|
71
127
|
topic?: string | null;
|
|
@@ -107,6 +163,8 @@ declare class Guild extends Base {
|
|
|
107
163
|
bannerURL(options?: {
|
|
108
164
|
size?: number;
|
|
109
165
|
}): string | null;
|
|
166
|
+
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
167
|
+
fetchWebhooks(): Promise<Webhook[]>;
|
|
110
168
|
}
|
|
111
169
|
|
|
112
170
|
declare class GuildMember extends Base {
|
|
@@ -127,6 +185,8 @@ declare class GuildMember extends Base {
|
|
|
127
185
|
interface ClientOptions {
|
|
128
186
|
rest?: Partial<ConstructorParameters<typeof REST>[0]>;
|
|
129
187
|
intents?: number;
|
|
188
|
+
/** Initial presence (status, custom_status, etc.) sent on identify. Can also update via PresenceUpdate after connect. */
|
|
189
|
+
presence?: GatewayPresenceUpdateData;
|
|
130
190
|
/** Optional WebSocket constructor (e.g. `require('ws')` in Node for compatibility) */
|
|
131
191
|
WebSocket?: new (url: string) => {
|
|
132
192
|
send(data: string | ArrayBufferLike): void;
|
|
@@ -147,6 +207,10 @@ declare const Events: {
|
|
|
147
207
|
readonly MessageCreate: "messageCreate";
|
|
148
208
|
readonly MessageUpdate: "messageUpdate";
|
|
149
209
|
readonly MessageDelete: "messageDelete";
|
|
210
|
+
readonly MessageReactionAdd: "messageReactionAdd";
|
|
211
|
+
readonly MessageReactionRemove: "messageReactionRemove";
|
|
212
|
+
readonly MessageReactionRemoveAll: "messageReactionRemoveAll";
|
|
213
|
+
readonly MessageReactionRemoveEmoji: "messageReactionRemoveEmoji";
|
|
150
214
|
readonly InteractionCreate: "interactionCreate";
|
|
151
215
|
readonly GuildCreate: "guildCreate";
|
|
152
216
|
readonly GuildUpdate: "guildUpdate";
|
|
@@ -172,6 +236,10 @@ interface ClientEvents {
|
|
|
172
236
|
id: string;
|
|
173
237
|
channelId: string;
|
|
174
238
|
}];
|
|
239
|
+
[Events.MessageReactionAdd]: [data: GatewayMessageReactionAddDispatchData];
|
|
240
|
+
[Events.MessageReactionRemove]: [data: GatewayMessageReactionRemoveDispatchData];
|
|
241
|
+
[Events.MessageReactionRemoveAll]: [data: GatewayMessageReactionRemoveAllDispatchData];
|
|
242
|
+
[Events.MessageReactionRemoveEmoji]: [data: GatewayMessageReactionRemoveEmojiDispatchData];
|
|
175
243
|
[Events.InteractionCreate]: [interaction: _fluxerjs_types.APIApplicationCommandInteraction];
|
|
176
244
|
[Events.GuildCreate]: [guild: Guild];
|
|
177
245
|
[Events.GuildUpdate]: [oldGuild: Guild, newGuild: Guild];
|
|
@@ -225,4 +293,4 @@ declare const ErrorCodes: {
|
|
|
225
293
|
readonly InvalidToken: "INVALID_TOKEN";
|
|
226
294
|
};
|
|
227
295
|
|
|
228
|
-
export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, TextChannel, User, VoiceChannel };
|
|
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 };
|