lunibee 0.2.1 → 0.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/README.md +6 -6
- package/dist/builders/attachment.d.ts +5 -1
- package/dist/builders/commands.d.ts +131 -45
- package/dist/builders/components.d.ts +164 -45
- package/dist/builders/embed.d.ts +5 -1
- package/dist/builders/index.d.ts +9 -4
- package/dist/builders/index.js +197 -105
- package/dist/builders/index.js.map +8 -8
- package/dist/core/events.d.ts +28 -12
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +183 -56
- package/dist/core/index.js.map +13 -13
- package/dist/core/permissions.d.ts +6 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +413 -168
- package/dist/index.js.map +17 -17
- package/dist/managers/index.d.ts +5 -1
- package/dist/managers/index.js +30 -14
- package/dist/managers/index.js.map +9 -9
- package/dist/managers/message.d.ts +7 -3
- package/dist/rest/index.js +2 -2
- package/dist/rest/index.js.map +1 -1
- package/dist/sharding/index.js +3 -2
- package/dist/sharding/index.js.map +4 -4
- package/dist/structures/index.d.ts +9 -3
- package/dist/structures/index.js +126 -28
- package/dist/structures/index.js.map +9 -9
- package/dist/structures/interactions.d.ts +85 -11
- package/dist/structures/resources.d.ts +11 -1
- package/dist/types/gateway.d.ts +14 -0
- package/dist/types/index.d.ts +179 -16
- package/dist/types/index.js +37 -10
- package/dist/types/index.js.map +4 -4
- package/dist/ws/index.js +2 -1
- package/dist/ws/index.js.map +4 -4
- package/package.json +14 -14
package/dist/managers/index.d.ts
CHANGED
|
@@ -42,9 +42,13 @@ export type ChannelEditOptions = Record<string, unknown>;
|
|
|
42
42
|
import { PermissionOverwriteManager } from "./guild-resources.js";
|
|
43
43
|
export declare class ChannelManager extends Manager<string, Channel> {
|
|
44
44
|
#private;
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* @param options.messageCache Enables a bounded per-channel message cache; messages are not cached by default.
|
|
47
|
+
* @param options.allowedMentions Default `allowed_mentions` for sends and edits without their own.
|
|
48
|
+
*/
|
|
46
49
|
constructor(rest: REST, options?: {
|
|
47
50
|
messageCache?: MessageCacheOptions;
|
|
51
|
+
allowedMentions?: unknown;
|
|
48
52
|
});
|
|
49
53
|
messages(channelId: string): MessageManager;
|
|
50
54
|
/** Permission overwrite manager for a channel. */
|
package/dist/managers/index.js
CHANGED
|
@@ -651,7 +651,7 @@ class ResourceManager extends Manager {
|
|
|
651
651
|
// packages/rest/package.json
|
|
652
652
|
var package_default = {
|
|
653
653
|
name: "@lunibee/rest",
|
|
654
|
-
version: "0.2.
|
|
654
|
+
version: "0.2.2",
|
|
655
655
|
type: "module",
|
|
656
656
|
module: "./src/index.ts",
|
|
657
657
|
types: "./src/index.ts",
|
|
@@ -1674,7 +1674,7 @@ class TextChannel extends Channel {
|
|
|
1674
1674
|
return `<#${this.id}>`;
|
|
1675
1675
|
}
|
|
1676
1676
|
}
|
|
1677
|
-
class
|
|
1677
|
+
class Emoji2 extends BaseStructure {
|
|
1678
1678
|
name;
|
|
1679
1679
|
roleIds;
|
|
1680
1680
|
user;
|
|
@@ -1821,7 +1821,7 @@ class ForumChannel extends Channel {
|
|
|
1821
1821
|
|
|
1822
1822
|
class MediaChannel extends ForumChannel {
|
|
1823
1823
|
}
|
|
1824
|
-
function
|
|
1824
|
+
function createChannel(data, context) {
|
|
1825
1825
|
switch (data.type) {
|
|
1826
1826
|
case 0:
|
|
1827
1827
|
return new TextChannel(data, context);
|
|
@@ -1873,6 +1873,9 @@ class Message extends BaseStructure {
|
|
|
1873
1873
|
reference;
|
|
1874
1874
|
components;
|
|
1875
1875
|
referencedMessage;
|
|
1876
|
+
stickers;
|
|
1877
|
+
poll;
|
|
1878
|
+
messageSnapshots;
|
|
1876
1879
|
member;
|
|
1877
1880
|
#context;
|
|
1878
1881
|
constructor(data, context) {
|
|
@@ -1894,6 +1897,13 @@ class Message extends BaseStructure {
|
|
|
1894
1897
|
this.mentionEveryone = data.mention_everyone ?? false;
|
|
1895
1898
|
this.type = data.type ?? 0;
|
|
1896
1899
|
this.reference = data.message_reference;
|
|
1900
|
+
this.stickers = data.sticker_items ?? (data.stickers ?? []).map(({ id, name, format_type }) => ({
|
|
1901
|
+
id,
|
|
1902
|
+
name,
|
|
1903
|
+
format_type
|
|
1904
|
+
}));
|
|
1905
|
+
this.poll = data.poll ?? null;
|
|
1906
|
+
this.messageSnapshots = data.message_snapshots ?? [];
|
|
1897
1907
|
this.referencedMessage = data.referenced_message ? new Message(data.referenced_message, context) : data.referenced_message === null ? null : undefined;
|
|
1898
1908
|
this.#context = context;
|
|
1899
1909
|
this.member = data.member && data.guild_id ? new GuildMember({
|
|
@@ -2028,8 +2038,10 @@ class Message extends BaseStructure {
|
|
|
2028
2038
|
}
|
|
2029
2039
|
|
|
2030
2040
|
// packages/managers/src/message.ts
|
|
2031
|
-
function toRequest(options) {
|
|
2041
|
+
function toRequest(options, allowedMentions) {
|
|
2032
2042
|
const { files, ...body } = options;
|
|
2043
|
+
if (allowedMentions !== undefined && body.allowed_mentions === undefined)
|
|
2044
|
+
body.allowed_mentions = allowedMentions;
|
|
2033
2045
|
if (!files?.length)
|
|
2034
2046
|
return body;
|
|
2035
2047
|
return {
|
|
@@ -2048,9 +2060,11 @@ class MessageManager {
|
|
|
2048
2060
|
#rest;
|
|
2049
2061
|
#context;
|
|
2050
2062
|
#channelId;
|
|
2051
|
-
|
|
2063
|
+
#allowedMentions;
|
|
2064
|
+
constructor(rest, context, channelId, cache, allowedMentions) {
|
|
2052
2065
|
if (!channelId)
|
|
2053
2066
|
throw new TypeError("Channel ID is required.");
|
|
2067
|
+
this.#allowedMentions = allowedMentions;
|
|
2054
2068
|
this.#rest = rest;
|
|
2055
2069
|
this.#context = context;
|
|
2056
2070
|
this.#channelId = channelId;
|
|
@@ -2064,7 +2078,7 @@ class MessageManager {
|
|
|
2064
2078
|
return this.cache.get(messageId) ?? this.fetch(messageId);
|
|
2065
2079
|
}
|
|
2066
2080
|
async send(options) {
|
|
2067
|
-
const data = await this.#rest.post(Routes.channelMessages(this.#channelId), toRequest(options));
|
|
2081
|
+
const data = await this.#rest.post(Routes.channelMessages(this.#channelId), toRequest(options, this.#allowedMentions));
|
|
2068
2082
|
return this.upsert(data);
|
|
2069
2083
|
}
|
|
2070
2084
|
async fetch(messageId) {
|
|
@@ -2108,7 +2122,7 @@ class ThreadManager {
|
|
|
2108
2122
|
auto_archive_duration: options.autoArchiveDuration,
|
|
2109
2123
|
rate_limit_per_user: options.rateLimitPerUser
|
|
2110
2124
|
});
|
|
2111
|
-
return
|
|
2125
|
+
return createChannel(data, this.#context);
|
|
2112
2126
|
}
|
|
2113
2127
|
}
|
|
2114
2128
|
|
|
@@ -2146,7 +2160,7 @@ class EmojiManager extends Manager {
|
|
|
2146
2160
|
this.#guildId = guildId;
|
|
2147
2161
|
}
|
|
2148
2162
|
fetch(emojiId) {
|
|
2149
|
-
return this.fetchOnce(emojiId, async () => new
|
|
2163
|
+
return this.fetchOnce(emojiId, async () => new Emoji2(await this.#rest.get(Routes.guildEmoji(this.#guildId, emojiId))), (emoji) => this.#merge(emojiId, emoji));
|
|
2150
2164
|
}
|
|
2151
2165
|
async fetchAll() {
|
|
2152
2166
|
const data = await this.#rest.get(Routes.guildEmoji(this.#guildId));
|
|
@@ -2164,7 +2178,7 @@ class EmojiManager extends Manager {
|
|
|
2164
2178
|
}
|
|
2165
2179
|
upsert(data) {
|
|
2166
2180
|
const key = data.id != null ? data.id : `unicode:${data.name ?? ""}`;
|
|
2167
|
-
return this.#merge(key, new
|
|
2181
|
+
return this.#merge(key, new Emoji2(data));
|
|
2168
2182
|
}
|
|
2169
2183
|
#merge(key, emoji) {
|
|
2170
2184
|
const existing = this.get(key);
|
|
@@ -2860,10 +2874,12 @@ class ChannelManager extends Manager {
|
|
|
2860
2874
|
#context;
|
|
2861
2875
|
#messageManagers = new Map;
|
|
2862
2876
|
#messageCache;
|
|
2877
|
+
#allowedMentions;
|
|
2863
2878
|
constructor(rest, options = {}) {
|
|
2864
2879
|
super();
|
|
2865
2880
|
this.#rest = rest;
|
|
2866
2881
|
this.#messageCache = options.messageCache;
|
|
2882
|
+
this.#allowedMentions = options.allowedMentions;
|
|
2867
2883
|
this.#context = {
|
|
2868
2884
|
sendMessage: (channelId, options) => this.send(channelId, options),
|
|
2869
2885
|
editMessage: (channelId, messageId, options) => this.editMessage(channelId, messageId, options),
|
|
@@ -2882,7 +2898,7 @@ class ChannelManager extends Manager {
|
|
|
2882
2898
|
messages(channelId) {
|
|
2883
2899
|
let manager = this.#messageManagers.get(channelId);
|
|
2884
2900
|
if (!manager) {
|
|
2885
|
-
manager = new MessageManager(this.#rest, this.#context, channelId, this.#messageCache);
|
|
2901
|
+
manager = new MessageManager(this.#rest, this.#context, channelId, this.#messageCache, this.#allowedMentions);
|
|
2886
2902
|
this.#messageManagers.set(channelId, manager);
|
|
2887
2903
|
}
|
|
2888
2904
|
return manager;
|
|
@@ -2894,13 +2910,13 @@ class ChannelManager extends Manager {
|
|
|
2894
2910
|
return new ThreadManager(this.#rest, this.#context, channelId);
|
|
2895
2911
|
}
|
|
2896
2912
|
fetch(channelId) {
|
|
2897
|
-
return this.fetchOnce(channelId, async () =>
|
|
2913
|
+
return this.fetchOnce(channelId, async () => createChannel(await this.#rest.get(Routes.channel(channelId)), this.#context), (channel) => this.#merge(channel));
|
|
2898
2914
|
}
|
|
2899
2915
|
async resolve(channelId) {
|
|
2900
2916
|
return this.get(channelId) ?? this.fetch(channelId);
|
|
2901
2917
|
}
|
|
2902
2918
|
upsert(data) {
|
|
2903
|
-
return this.#merge(
|
|
2919
|
+
return this.#merge(createChannel(data, this.#context));
|
|
2904
2920
|
}
|
|
2905
2921
|
#merge(channel) {
|
|
2906
2922
|
const existing = this.get(channel.id);
|
|
@@ -2988,7 +3004,7 @@ class ChannelManager extends Manager {
|
|
|
2988
3004
|
return this.messages(data.channel_id).upsert(data);
|
|
2989
3005
|
}
|
|
2990
3006
|
async editMessage(channelId, messageId, options) {
|
|
2991
|
-
return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), toRequest(options)));
|
|
3007
|
+
return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), toRequest(options, this.#allowedMentions)));
|
|
2992
3008
|
}
|
|
2993
3009
|
async deleteMessage(channelId, messageId) {
|
|
2994
3010
|
await this.#rest.delete(Routes.message(channelId, messageId));
|
|
@@ -3115,4 +3131,4 @@ export {
|
|
|
3115
3131
|
toRequest
|
|
3116
3132
|
};
|
|
3117
3133
|
|
|
3118
|
-
//# debugId=
|
|
3134
|
+
//# debugId=EB58705923B2D19264756E2164756E21
|