seyfert 3.2.1-dev-15624887796.0 → 3.2.1-dev-15657234528.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/lib/common/shorters/threads.d.ts +3 -2
- package/lib/common/shorters/threads.js +23 -12
- package/lib/components/componentcommand.d.ts +1 -1
- package/lib/components/componentcommand.js +5 -2
- package/lib/components/handler.d.ts +1 -0
- package/lib/components/handler.js +17 -0
- package/lib/langs/router.d.ts +1 -1
- package/lib/langs/router.js +3 -1
- package/lib/structures/Guild.d.ts +2 -1
- package/lib/structures/Guild.js +3 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ThreadChannelStructure } from '../../client/transformers';
|
|
2
|
-
import type
|
|
2
|
+
import { type APIThreadMember, type RESTGetAPIChannelThreadMembersQuery, type RESTGetAPIChannelThreadsArchivedQuery, type RESTPatchAPIChannelJSONBody, type RESTPostAPIChannelMessagesThreadsJSONBody, type RESTPostAPIChannelThreadsJSONBody, type RESTPostAPIGuildForumThreadsJSONBody } from '../../types';
|
|
3
3
|
import type { MakeRequired, When } from '../types/util';
|
|
4
4
|
import { BaseShorter } from './base';
|
|
5
5
|
export declare class ThreadShorter extends BaseShorter {
|
|
@@ -21,11 +21,12 @@ export declare class ThreadShorter extends BaseShorter {
|
|
|
21
21
|
fetchMember<WithMember extends boolean = false>(threadId: string, memberId: string, with_member: WithMember): Promise<When<WithMember, Required<APIThreadMember>, GetAPIChannelThreadMemberResult>>;
|
|
22
22
|
addMember(threadId: string, memberId: string): Promise<undefined>;
|
|
23
23
|
listMembers<T extends RESTGetAPIChannelThreadMembersQuery = RESTGetAPIChannelThreadMembersQuery>(threadId: string, query?: T): Promise<InferWithMemberOnList<T>>;
|
|
24
|
-
|
|
24
|
+
listArchived(channelId: string, type: 'public' | 'private', query?: RESTGetAPIChannelThreadsArchivedQuery): Promise<{
|
|
25
25
|
threads: ThreadChannelStructure[];
|
|
26
26
|
members: GetAPIChannelThreadMemberResult[];
|
|
27
27
|
hasMore: boolean;
|
|
28
28
|
}>;
|
|
29
|
+
listGuildActive(guildId: string, force?: boolean): Promise<ThreadChannelStructure[]>;
|
|
29
30
|
listJoinedArchivedPrivate(channelId: string, query?: RESTGetAPIChannelThreadsArchivedQuery): Promise<{
|
|
30
31
|
threads: ThreadChannelStructure[];
|
|
31
32
|
members: GetAPIChannelThreadMemberResult[];
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ThreadShorter = void 0;
|
|
4
4
|
const __1 = require("../..");
|
|
5
5
|
const structures_1 = require("../../structures");
|
|
6
|
+
const types_1 = require("../../types");
|
|
6
7
|
const base_1 = require("./base");
|
|
7
8
|
class ThreadShorter extends base_1.BaseShorter {
|
|
8
9
|
/**
|
|
@@ -21,16 +22,11 @@ class ThreadShorter extends base_1.BaseShorter {
|
|
|
21
22
|
return (0, structures_1.channelFrom)(thread, this.client);
|
|
22
23
|
}));
|
|
23
24
|
}
|
|
24
|
-
fromMessage(channelId, messageId, options) {
|
|
25
|
+
async fromMessage(channelId, messageId, options) {
|
|
25
26
|
const { reason, ...body } = options;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.threads.post({ body, reason })
|
|
30
|
-
.then(async (thread) => {
|
|
31
|
-
await this.client.cache.channels?.setIfNI(__1.CacheFrom.Rest, 'Guilds', thread.id, thread.guild_id, thread);
|
|
32
|
-
return (0, structures_1.channelFrom)(thread, this.client);
|
|
33
|
-
});
|
|
27
|
+
const thread = await this.client.proxy.channels(channelId).messages(messageId).threads.post({ body, reason });
|
|
28
|
+
await this.client.cache.channels?.setIfNI(__1.CacheFrom.Rest, 'Guilds', thread.id, thread.guild_id, thread);
|
|
29
|
+
return await (0, structures_1.channelFrom)(thread, this.client);
|
|
34
30
|
}
|
|
35
31
|
join(threadId) {
|
|
36
32
|
return this.client.proxy.channels(threadId)['thread-members']('@me').put();
|
|
@@ -38,8 +34,9 @@ class ThreadShorter extends base_1.BaseShorter {
|
|
|
38
34
|
leave(threadId) {
|
|
39
35
|
return this.client.proxy.channels(threadId)['thread-members']('@me').delete();
|
|
40
36
|
}
|
|
41
|
-
lock(threadId, locked = true, reason) {
|
|
42
|
-
|
|
37
|
+
async lock(threadId, locked = true, reason) {
|
|
38
|
+
const x = await this.edit(threadId, { locked }, reason);
|
|
39
|
+
return (0, structures_1.channelFrom)(x, this.client);
|
|
43
40
|
}
|
|
44
41
|
async edit(threadId, body, reason) {
|
|
45
42
|
return (await this.client.channels.edit(threadId, body, { reason }));
|
|
@@ -60,7 +57,7 @@ class ThreadShorter extends base_1.BaseShorter {
|
|
|
60
57
|
listMembers(threadId, query) {
|
|
61
58
|
return this.client.proxy.channels(threadId)['thread-members'].get({ query });
|
|
62
59
|
}
|
|
63
|
-
async
|
|
60
|
+
async listArchived(channelId, type, query) {
|
|
64
61
|
const data = await this.client.proxy.channels(channelId).threads.archived[type].get({ query });
|
|
65
62
|
return {
|
|
66
63
|
threads: data.threads.map(thread => (0, structures_1.channelFrom)(thread, this.client)),
|
|
@@ -68,6 +65,20 @@ class ThreadShorter extends base_1.BaseShorter {
|
|
|
68
65
|
hasMore: data.has_more,
|
|
69
66
|
};
|
|
70
67
|
}
|
|
68
|
+
async listGuildActive(guildId, force = false) {
|
|
69
|
+
if (!force) {
|
|
70
|
+
const cached = await this.client.cache.channels?.valuesRaw(guildId);
|
|
71
|
+
if (cached)
|
|
72
|
+
return cached
|
|
73
|
+
.filter(x => [types_1.ChannelType.PublicThread, types_1.ChannelType.PrivateThread, types_1.ChannelType.AnnouncementThread].includes(x.type))
|
|
74
|
+
.map(x => (0, structures_1.channelFrom)(x, this.client));
|
|
75
|
+
}
|
|
76
|
+
const data = await this.client.proxy.guilds(guildId).threads.active.get();
|
|
77
|
+
return Promise.all(data.threads.map(async (thread) => {
|
|
78
|
+
await this.client.cache.channels?.setIfNI(__1.CacheFrom.Rest, 'Guilds', thread.id, guildId, thread);
|
|
79
|
+
return (0, structures_1.channelFrom)(thread, this.client);
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
71
82
|
async listJoinedArchivedPrivate(channelId, query) {
|
|
72
83
|
const data = await this.client.proxy.channels(channelId).users('@me').threads.archived.private.get({ query });
|
|
73
84
|
return {
|
|
@@ -10,7 +10,7 @@ export interface ComponentCommand {
|
|
|
10
10
|
export declare abstract class ComponentCommand {
|
|
11
11
|
type: 0;
|
|
12
12
|
abstract componentType: keyof ContextComponentCommandInteractionMap;
|
|
13
|
-
customId?: string;
|
|
13
|
+
customId?: string | RegExp;
|
|
14
14
|
filter?(context: ComponentContext<typeof this.componentType>): Promise<boolean> | boolean;
|
|
15
15
|
abstract run(context: ComponentContext<typeof this.componentType>): any;
|
|
16
16
|
middlewares: (keyof RegisteredMiddlewares)[];
|
|
@@ -11,8 +11,11 @@ class ComponentCommand {
|
|
|
11
11
|
customId;
|
|
12
12
|
/** @internal */
|
|
13
13
|
_filter(context) {
|
|
14
|
-
if (this.customId
|
|
15
|
-
|
|
14
|
+
if (this.customId) {
|
|
15
|
+
const matches = typeof this.customId === 'string' ? this.customId === context.customId : context.customId.match(this.customId);
|
|
16
|
+
if (!matches)
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
16
19
|
if (this.filter)
|
|
17
20
|
return this.filter(context);
|
|
18
21
|
return true;
|
|
@@ -29,6 +29,7 @@ export type ComponentCommands = ComponentCommand | ModalCommand;
|
|
|
29
29
|
export interface CreateComponentCollectorResult {
|
|
30
30
|
run<T extends CollectorInteraction = CollectorInteraction>(customId: UserMatches, callback: ComponentCallback<T>): void;
|
|
31
31
|
stop(reason?: string): void;
|
|
32
|
+
waitFor<T extends CollectorInteraction = CollectorInteraction>(customId: UserMatches): Promise<T | null>;
|
|
32
33
|
resetTimeouts(): void;
|
|
33
34
|
}
|
|
34
35
|
export declare class ComponentHandler extends BaseHandler {
|
|
@@ -73,6 +73,23 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
73
73
|
this.createComponentCollector(messageId, channelId, guildId, options, old.components);
|
|
74
74
|
});
|
|
75
75
|
},
|
|
76
|
+
waitFor: customId => new Promise(resolve => {
|
|
77
|
+
const collector = this.values.get(messageId);
|
|
78
|
+
if (!collector)
|
|
79
|
+
return resolve(null);
|
|
80
|
+
this.values.get(messageId).__run(customId, interaction => {
|
|
81
|
+
this.clearValue(messageId);
|
|
82
|
+
//@ts-expect-error generic
|
|
83
|
+
resolve(interaction);
|
|
84
|
+
});
|
|
85
|
+
if (collector?.timeout)
|
|
86
|
+
clearTimeout(collector.timeout);
|
|
87
|
+
collector.timeout = setTimeout(() => {
|
|
88
|
+
this.clearValue(messageId);
|
|
89
|
+
resolve(null);
|
|
90
|
+
// by default 15 seconds in case user don't do anything
|
|
91
|
+
}, collector?.options?.timeout ?? 15_000);
|
|
92
|
+
}),
|
|
76
93
|
resetTimeouts: () => {
|
|
77
94
|
this.resetTimeouts(messageId);
|
|
78
95
|
},
|
package/lib/langs/router.d.ts
CHANGED
package/lib/langs/router.js
CHANGED
|
@@ -13,6 +13,8 @@ const LangRouter = (userLocale, defaultLang, langs) => {
|
|
|
13
13
|
if (typeof locale === 'undefined')
|
|
14
14
|
throw new Error('Undefined locale');
|
|
15
15
|
let value = langs[locale];
|
|
16
|
+
if (typeof value === 'undefined')
|
|
17
|
+
throw new Error(`Locale "${locale}" not found`);
|
|
16
18
|
for (const i of route)
|
|
17
19
|
value = value[i];
|
|
18
20
|
return value;
|
|
@@ -39,4 +41,4 @@ const LangRouter = (userLocale, defaultLang, langs) => {
|
|
|
39
41
|
return createProxy;
|
|
40
42
|
};
|
|
41
43
|
exports.LangRouter = LangRouter;
|
|
42
|
-
/**Idea inspiration from: FreeAoi */
|
|
44
|
+
/**Idea inspiration from: FreeAoi | Fixed by: Drylozu */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GuildMemberStructure, GuildStructure } from '../client';
|
|
1
|
+
import type { GuildMemberStructure, GuildStructure, ThreadChannelStructure } from '../client';
|
|
2
2
|
import type { UsingClient } from '../commands';
|
|
3
3
|
import type { CreateInviteFromChannel } from '../common';
|
|
4
4
|
import type { ObjectToLower, StructPropState, StructStates, ToClass } from '../common/types/util';
|
|
@@ -20,6 +20,7 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
|
|
|
20
20
|
get maxStickers(): MaxStickers;
|
|
21
21
|
get maxEmojis(): MaxEmojis;
|
|
22
22
|
fetchOwner(force?: boolean): Promise<GuildMemberStructure | null>;
|
|
23
|
+
listActiveThreads(force?: boolean): Promise<ThreadChannelStructure[]>;
|
|
23
24
|
templates: {
|
|
24
25
|
fetch: (code: string) => Promise<import("../client").GuildTemplateStructure>;
|
|
25
26
|
list: () => Promise<import("../client").GuildTemplateStructure[]>;
|
package/lib/structures/Guild.js
CHANGED
|
@@ -56,6 +56,9 @@ class Guild extends BaseGuild_1.BaseGuild {
|
|
|
56
56
|
}
|
|
57
57
|
return this.members.fetch(this.ownerId, force);
|
|
58
58
|
}
|
|
59
|
+
listActiveThreads(force = false) {
|
|
60
|
+
return this.client.threads.listGuildActive(this.id, force);
|
|
61
|
+
}
|
|
59
62
|
templates = GuildTemplate_1.GuildTemplate.methods({ client: this.client, guildId: this.id });
|
|
60
63
|
stickers = Sticker_1.Sticker.methods({ client: this.client, guildId: this.id });
|
|
61
64
|
members = GuildMember_1.GuildMember.methods({ client: this.client, guildId: this.id });
|