seyfert 1.4.0 → 1.5.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/README.md +7 -7
- package/lib/api/Router.js +3 -1
- package/lib/api/Routes/guilds.d.ts +4 -1
- package/lib/cache/index.d.ts +6 -2
- package/lib/cache/index.js +18 -0
- package/lib/cache/resources/bans.d.ts +12 -0
- package/lib/cache/resources/bans.js +35 -0
- package/lib/cache/resources/members.js +4 -4
- package/lib/cache/resources/messages.js +8 -6
- package/lib/client/base.d.ts +7 -3
- package/lib/client/base.js +43 -24
- package/lib/client/client.d.ts +17 -5
- package/lib/client/client.js +39 -43
- package/lib/client/collectors.d.ts +36 -0
- package/lib/client/collectors.js +85 -0
- package/lib/client/httpclient.js +6 -6
- package/lib/client/onmessagecreate.d.ts +12 -2
- package/lib/client/onmessagecreate.js +32 -17
- package/lib/client/workerclient.d.ts +4 -1
- package/lib/client/workerclient.js +59 -67
- package/lib/collection.d.ts +2 -2
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +10 -9
- package/lib/commands/applications/chat.js +21 -7
- package/lib/commands/applications/menu.d.ts +8 -7
- package/lib/commands/applications/menu.js +3 -2
- package/lib/commands/applications/shared.d.ts +12 -0
- package/lib/commands/decorators.d.ts +11 -17
- package/lib/commands/decorators.js +7 -14
- package/lib/commands/handler.js +39 -29
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +3 -1
- package/lib/common/it/formatter.d.ts +155 -0
- package/lib/common/it/formatter.js +184 -0
- package/lib/common/it/logger.js +5 -5
- package/lib/common/it/utils.js +2 -4
- package/lib/common/shorters/bans.d.ts +43 -0
- package/lib/common/shorters/bans.js +78 -0
- package/lib/common/shorters/emojis.d.ts +1 -1
- package/lib/common/shorters/emojis.js +4 -3
- package/lib/common/shorters/interaction.js +9 -7
- package/lib/common/shorters/messages.js +2 -2
- package/lib/common/shorters/webhook.js +2 -2
- package/lib/components/componentcommand.d.ts +3 -2
- package/lib/components/componentcommand.js +2 -1
- package/lib/components/componentcontext.d.ts +1 -1
- package/lib/components/handler.d.ts +1 -1
- package/lib/components/handler.js +25 -28
- package/lib/components/modalcommand.d.ts +2 -1
- package/lib/components/modalcommand.js +1 -0
- package/lib/components/modalcontext.d.ts +1 -1
- package/lib/events/event.d.ts +4 -3
- package/lib/events/handler.d.ts +8 -5
- package/lib/events/handler.js +58 -13
- package/lib/events/hooks/guild.d.ts +18 -73
- package/lib/events/hooks/integration.d.ts +57 -0
- package/lib/events/hooks/invite.d.ts +3 -0
- package/lib/events/hooks/message.d.ts +11 -6
- package/lib/events/hooks/presence.d.ts +4 -0
- package/lib/events/hooks/thread.d.ts +14 -3
- package/lib/events/hooks/typing.d.ts +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -2
- package/lib/structures/Guild.d.ts +9 -1
- package/lib/structures/Guild.js +2 -0
- package/lib/structures/GuildBan.d.ts +25 -0
- package/lib/structures/GuildBan.js +36 -0
- package/lib/structures/GuildEmoji.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +7 -2
- package/lib/structures/GuildMember.js +4 -4
- package/lib/structures/Interaction.d.ts +3 -2
- package/lib/structures/Interaction.js +21 -9
- package/lib/structures/Message.d.ts +69 -8
- package/lib/structures/Message.js +59 -17
- package/lib/structures/Sticker.d.ts +3 -3
- package/lib/structures/User.d.ts +1 -0
- package/lib/structures/User.js +4 -1
- package/lib/structures/channels.d.ts +4 -1
- package/lib/structures/channels.js +36 -6
- package/lib/structures/extra/functions.js +1 -1
- package/lib/websocket/discord/basesocket.d.ts +1 -0
- package/lib/websocket/discord/basesocket.js +17 -0
- package/lib/websocket/discord/shard.d.ts +1 -0
- package/lib/websocket/discord/shard.js +6 -0
- package/package.json +8 -8
|
@@ -120,12 +120,12 @@ class GuildMember extends BaseGuildMember {
|
|
|
120
120
|
write(body) {
|
|
121
121
|
return this.user.write(body);
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
return this.user.
|
|
123
|
+
defaultAvatarURL() {
|
|
124
|
+
return this.user.defaultAvatarURL();
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
avatarURL(options) {
|
|
127
127
|
if (!this.avatar) {
|
|
128
|
-
return this.user.avatarURL(
|
|
128
|
+
return options?.exclude ? null : this.user.avatarURL();
|
|
129
129
|
}
|
|
130
130
|
return this.rest.cdn.guilds(this.guildId).users(this.id).avatars(this.avatar).get(options);
|
|
131
131
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type APIApplicationCommandAutocompleteInteraction, type APIApplicationCommandInteraction, type APIBaseInteraction, type APIChatInputApplicationCommandInteraction, type APIChatInputApplicationCommandInteractionData, type APICommandAutocompleteInteractionResponseCallbackData, type APIInteraction, type APIInteractionResponse, type APIInteractionResponseChannelMessageWithSource, type APIInteractionResponseDeferredChannelMessageWithSource, type APIInteractionResponseDeferredMessageUpdate, type APIInteractionResponsePong, type APIInteractionResponseUpdateMessage, type APIMessageApplicationCommandInteraction, type APIMessageApplicationCommandInteractionData, type APIMessageButtonInteractionData, type APIMessageComponentInteraction, type APIMessageComponentSelectMenuInteraction, type APIMessageStringSelectInteractionData, type APIModalSubmission, type APIModalSubmitInteraction, type APIUserApplicationCommandInteraction, type APIUserApplicationCommandInteractionData, ApplicationCommandType, ComponentType, type GatewayInteractionCreateDispatchData, InteractionResponseType, InteractionType, type MessageFlags, type RESTPostAPIInteractionCallbackJSONBody } from 'discord-api-types/v10';
|
|
2
|
+
import type { RawFile } from '../api';
|
|
2
3
|
import { OptionResolver, type UsingClient } from '../commands';
|
|
3
4
|
import type { ObjectToLower, OmitInsert, ToClass, When } from '../common';
|
|
4
5
|
import type { ComponentInteractionMessageUpdate, InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MessageCreateBodyRequest, MessageUpdateBodyRequest, MessageWebhookCreateBodyRequest, ModalCreateBodyRequest } from '../common/types/write';
|
|
@@ -27,8 +28,8 @@ export declare class BaseInteraction<FromGuild extends boolean = boolean, Type e
|
|
|
27
28
|
replied?: Promise<boolean> | boolean;
|
|
28
29
|
appPermissions?: PermissionsBitField;
|
|
29
30
|
constructor(client: UsingClient, interaction: Type, __reply?: __InternalReplyFunction | undefined);
|
|
30
|
-
static transformBodyRequest(body: ReplyInteractionBody, self: UsingClient): APIInteractionResponse;
|
|
31
|
-
static transformBody<T>(body: InteractionMessageUpdateBodyRequest | MessageUpdateBodyRequest | MessageCreateBodyRequest | MessageWebhookCreateBodyRequest, self: UsingClient): T;
|
|
31
|
+
static transformBodyRequest(body: ReplyInteractionBody, files: RawFile[] | undefined, self: UsingClient): APIInteractionResponse;
|
|
32
|
+
static transformBody<T>(body: InteractionMessageUpdateBodyRequest | MessageUpdateBodyRequest | MessageCreateBodyRequest | MessageWebhookCreateBodyRequest, files: RawFile[] | undefined, self: UsingClient): T;
|
|
32
33
|
private matchReplied;
|
|
33
34
|
reply(body: ReplyInteractionBody): Promise<void>;
|
|
34
35
|
deferReply(flags?: MessageFlags): Promise<void>;
|
|
@@ -48,7 +48,7 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
48
48
|
}
|
|
49
49
|
this.user = this.member?.user ?? new User_1.User(client, interaction.user);
|
|
50
50
|
}
|
|
51
|
-
static transformBodyRequest(body, self) {
|
|
51
|
+
static transformBodyRequest(body, files, self) {
|
|
52
52
|
switch (body.type) {
|
|
53
53
|
case v10_1.InteractionResponseType.ApplicationCommandAutocompleteResult:
|
|
54
54
|
case v10_1.InteractionResponseType.DeferredMessageUpdate:
|
|
@@ -65,9 +65,14 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
65
65
|
allowed_mentions: self.options?.allowedMentions,
|
|
66
66
|
...(body.data ?? {}),
|
|
67
67
|
//@ts-ignore
|
|
68
|
-
components: body.data?.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x))
|
|
69
|
-
embeds: body.data?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x))
|
|
70
|
-
attachments: body.data
|
|
68
|
+
components: body.data?.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)),
|
|
69
|
+
embeds: body.data?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)),
|
|
70
|
+
attachments: body.data && 'attachments' in body.data
|
|
71
|
+
? body.data.attachments?.map((x, i) => ({ id: i, ...(0, builders_1.resolveAttachment)(x) }))
|
|
72
|
+
: files?.map((x, id) => ({
|
|
73
|
+
id,
|
|
74
|
+
filename: x.name,
|
|
75
|
+
})),
|
|
71
76
|
poll: poll ? (poll instanceof builders_1.PollBuilder ? poll.toJSON() : poll) : undefined,
|
|
72
77
|
},
|
|
73
78
|
};
|
|
@@ -90,13 +95,19 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
90
95
|
return body;
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
|
-
static transformBody(body, self) {
|
|
98
|
+
static transformBody(body, files, self) {
|
|
94
99
|
const poll = body.poll;
|
|
95
100
|
return {
|
|
96
101
|
allowed_mentions: self.options?.allowedMentions,
|
|
102
|
+
attachments: 'attachments' in body
|
|
103
|
+
? body.attachments?.map((x, i) => ({ id: i, ...(0, builders_1.resolveAttachment)(x) }))
|
|
104
|
+
: files?.map((x, id) => ({
|
|
105
|
+
id,
|
|
106
|
+
filename: x.name,
|
|
107
|
+
})),
|
|
97
108
|
...body,
|
|
98
|
-
components: body.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x))
|
|
99
|
-
embeds: body?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x))
|
|
109
|
+
components: body.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)),
|
|
110
|
+
embeds: body?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)),
|
|
100
111
|
poll: poll ? (poll instanceof builders_1.PollBuilder ? poll.toJSON() : poll) : undefined,
|
|
101
112
|
};
|
|
102
113
|
}
|
|
@@ -106,9 +117,10 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
106
117
|
const { files, ...rest } = body.data ?? {};
|
|
107
118
|
//@ts-expect-error
|
|
108
119
|
const data = body.data instanceof builders_1.Modal ? body.data : rest;
|
|
120
|
+
const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : undefined;
|
|
109
121
|
return (this.replied = this.__reply({
|
|
110
|
-
body: BaseInteraction.transformBodyRequest({ data, type: body.type }, this.client),
|
|
111
|
-
files:
|
|
122
|
+
body: BaseInteraction.transformBodyRequest({ data, type: body.type }, parsedFiles, this.client),
|
|
123
|
+
files: parsedFiles,
|
|
112
124
|
}).then(() => (this.replied = true)));
|
|
113
125
|
}
|
|
114
126
|
return (this.replied = this.client.interactions.reply(this.id, this.token, body).then(() => (this.replied = true)));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { APIChannelMention, APIMessage, GatewayMessageCreateDispatchData } from 'discord-api-types/v10';
|
|
1
|
+
import type { APIChannelMention, APIEmbed, APIMessage, GatewayMessageCreateDispatchData } from 'discord-api-types/v10';
|
|
2
2
|
import type { ListenerOptions } from '../builders';
|
|
3
3
|
import type { UsingClient } from '../commands';
|
|
4
|
-
import type
|
|
4
|
+
import { type ObjectToLower } from '../common';
|
|
5
5
|
import type { EmojiResolvable } from '../common/types/resolvables';
|
|
6
6
|
import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../common/types/write';
|
|
7
7
|
import type { ActionRowMessageComponents } from '../components';
|
|
@@ -10,13 +10,11 @@ import { GuildMember } from './GuildMember';
|
|
|
10
10
|
import { User } from './User';
|
|
11
11
|
import type { MessageWebhookMethodEditParams, MessageWebhookMethodWriteParams } from './Webhook';
|
|
12
12
|
import { DiscordBase } from './extra/DiscordBase';
|
|
13
|
-
import { Poll } from '..';
|
|
13
|
+
import { Embed, Poll } from '..';
|
|
14
14
|
export type MessageData = APIMessage | GatewayMessageCreateDispatchData;
|
|
15
|
-
export interface BaseMessage extends DiscordBase, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll'>> {
|
|
16
|
-
}
|
|
17
|
-
export declare class BaseMessage extends DiscordBase {
|
|
18
|
-
guildId: string | undefined;
|
|
15
|
+
export interface BaseMessage extends DiscordBase, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll' | 'embeds'>> {
|
|
19
16
|
timestamp?: number;
|
|
17
|
+
guildId?: string;
|
|
20
18
|
author: User;
|
|
21
19
|
member?: GuildMember;
|
|
22
20
|
components: MessageActionRowComponent<ActionRowMessageComponents>[];
|
|
@@ -26,6 +24,9 @@ export declare class BaseMessage extends DiscordBase {
|
|
|
26
24
|
channels: APIChannelMention[];
|
|
27
25
|
users: (GuildMember | User)[];
|
|
28
26
|
};
|
|
27
|
+
}
|
|
28
|
+
export declare class BaseMessage extends DiscordBase {
|
|
29
|
+
embeds: InMessageEmbed[];
|
|
29
30
|
constructor(client: UsingClient, data: MessageData);
|
|
30
31
|
get user(): User;
|
|
31
32
|
createComponentCollector(options?: ListenerOptions): {
|
|
@@ -38,7 +39,7 @@ export declare class BaseMessage extends DiscordBase {
|
|
|
38
39
|
react(emoji: EmojiResolvable): Promise<void>;
|
|
39
40
|
private patch;
|
|
40
41
|
}
|
|
41
|
-
export interface Message extends BaseMessage, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll'>> {
|
|
42
|
+
export interface Message extends BaseMessage, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll' | 'embeds'>> {
|
|
42
43
|
}
|
|
43
44
|
export declare class Message extends BaseMessage {
|
|
44
45
|
constructor(client: UsingClient, data: MessageData);
|
|
@@ -60,3 +61,63 @@ export declare class WebhookMessage extends BaseMessage {
|
|
|
60
61
|
write(body: WriteMessageWebhook): Promise<WebhookMessage | null>;
|
|
61
62
|
delete(reason?: string): Promise<never>;
|
|
62
63
|
}
|
|
64
|
+
export declare class InMessageEmbed {
|
|
65
|
+
data: APIEmbed;
|
|
66
|
+
constructor(data: APIEmbed);
|
|
67
|
+
get title(): string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated
|
|
70
|
+
*/
|
|
71
|
+
get type(): import("discord-api-types/v10").EmbedType | undefined;
|
|
72
|
+
get description(): string | undefined;
|
|
73
|
+
get url(): string | undefined;
|
|
74
|
+
get timestamp(): string | undefined;
|
|
75
|
+
get color(): number | undefined;
|
|
76
|
+
get footer(): {
|
|
77
|
+
text: string;
|
|
78
|
+
iconUrl?: string | undefined;
|
|
79
|
+
proxyIconUrl?: string | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
get image(): {
|
|
82
|
+
url: string;
|
|
83
|
+
proxyUrl?: string | undefined;
|
|
84
|
+
height?: number | undefined;
|
|
85
|
+
width?: number | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
get thumbnail(): {
|
|
88
|
+
url: string;
|
|
89
|
+
proxyUrl?: string | undefined;
|
|
90
|
+
height?: number | undefined;
|
|
91
|
+
width?: number | undefined;
|
|
92
|
+
} | undefined;
|
|
93
|
+
get video(): {
|
|
94
|
+
url?: string | undefined;
|
|
95
|
+
proxyUrl?: string | undefined;
|
|
96
|
+
height?: number | undefined;
|
|
97
|
+
width?: number | undefined;
|
|
98
|
+
} | undefined;
|
|
99
|
+
get provider(): import("discord-api-types/v10").APIEmbedProvider | undefined;
|
|
100
|
+
get author(): {
|
|
101
|
+
name: string;
|
|
102
|
+
url?: string | undefined;
|
|
103
|
+
iconUrl?: string | undefined;
|
|
104
|
+
proxyIconUrl?: string | undefined;
|
|
105
|
+
} | undefined;
|
|
106
|
+
get fields(): import("discord-api-types/v10").APIEmbedField[] | undefined;
|
|
107
|
+
toBuilder(): Embed;
|
|
108
|
+
toJSON(): {
|
|
109
|
+
title?: string | undefined;
|
|
110
|
+
type?: import("discord-api-types/v10").EmbedType | undefined;
|
|
111
|
+
description?: string | undefined;
|
|
112
|
+
url?: string | undefined;
|
|
113
|
+
timestamp?: string | undefined;
|
|
114
|
+
color?: number | undefined;
|
|
115
|
+
footer?: import("discord-api-types/v10").APIEmbedFooter | undefined;
|
|
116
|
+
image?: import("discord-api-types/v10").APIEmbedImage | undefined;
|
|
117
|
+
thumbnail?: import("discord-api-types/v10").APIEmbedThumbnail | undefined;
|
|
118
|
+
video?: import("discord-api-types/v10").APIEmbedVideo | undefined;
|
|
119
|
+
provider?: import("discord-api-types/v10").APIEmbedProvider | undefined;
|
|
120
|
+
author?: import("discord-api-types/v10").APIEmbedAuthor | undefined;
|
|
121
|
+
fields?: import("discord-api-types/v10").APIEmbedField[] | undefined;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebhookMessage = exports.Message = exports.BaseMessage = void 0;
|
|
3
|
+
exports.InMessageEmbed = exports.WebhookMessage = exports.Message = exports.BaseMessage = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
4
5
|
const ActionRow_1 = require("../components/ActionRow");
|
|
5
6
|
const GuildMember_1 = require("./GuildMember");
|
|
6
7
|
const User_1 = require("./User");
|
|
@@ -8,13 +9,7 @@ const DiscordBase_1 = require("./extra/DiscordBase");
|
|
|
8
9
|
const functions_1 = require("./extra/functions");
|
|
9
10
|
const __1 = require("..");
|
|
10
11
|
class BaseMessage extends DiscordBase_1.DiscordBase {
|
|
11
|
-
|
|
12
|
-
timestamp;
|
|
13
|
-
author;
|
|
14
|
-
member;
|
|
15
|
-
components;
|
|
16
|
-
poll;
|
|
17
|
-
mentions;
|
|
12
|
+
embeds;
|
|
18
13
|
constructor(client, data) {
|
|
19
14
|
super(client, data);
|
|
20
15
|
this.mentions = {
|
|
@@ -23,6 +18,7 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
|
|
|
23
18
|
users: [],
|
|
24
19
|
};
|
|
25
20
|
this.components = data.components?.map(x => new ActionRow_1.MessageActionRowComponent(x)) ?? [];
|
|
21
|
+
this.embeds = data.embeds.map(embed => new InMessageEmbed(embed));
|
|
26
22
|
this.patch(data);
|
|
27
23
|
}
|
|
28
24
|
get user() {
|
|
@@ -46,18 +42,9 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
|
|
|
46
42
|
return this.client.reactions.add(this.id, this.channelId, emoji);
|
|
47
43
|
}
|
|
48
44
|
patch(data) {
|
|
49
|
-
if ('guild_id' in data) {
|
|
50
|
-
this.guildId = data.guild_id;
|
|
51
|
-
}
|
|
52
|
-
if (data.type !== undefined) {
|
|
53
|
-
this.type = data.type;
|
|
54
|
-
}
|
|
55
45
|
if ('timestamp' in data && data.timestamp) {
|
|
56
46
|
this.timestamp = Date.parse(data.timestamp);
|
|
57
47
|
}
|
|
58
|
-
if ('application_id' in data) {
|
|
59
|
-
this.applicationId = data.application_id;
|
|
60
|
-
}
|
|
61
48
|
if ('author' in data && data.author) {
|
|
62
49
|
this.author = new User_1.User(this.client, data.author);
|
|
63
50
|
}
|
|
@@ -141,3 +128,58 @@ class WebhookMessage extends BaseMessage {
|
|
|
141
128
|
}
|
|
142
129
|
}
|
|
143
130
|
exports.WebhookMessage = WebhookMessage;
|
|
131
|
+
class InMessageEmbed {
|
|
132
|
+
data;
|
|
133
|
+
constructor(data) {
|
|
134
|
+
this.data = data;
|
|
135
|
+
}
|
|
136
|
+
get title() {
|
|
137
|
+
return this.data.title;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated
|
|
141
|
+
*/
|
|
142
|
+
get type() {
|
|
143
|
+
return this.data.type;
|
|
144
|
+
}
|
|
145
|
+
get description() {
|
|
146
|
+
return this.data.description;
|
|
147
|
+
}
|
|
148
|
+
get url() {
|
|
149
|
+
return this.data.url;
|
|
150
|
+
}
|
|
151
|
+
get timestamp() {
|
|
152
|
+
return this.data.timestamp;
|
|
153
|
+
}
|
|
154
|
+
get color() {
|
|
155
|
+
return this.data.color;
|
|
156
|
+
}
|
|
157
|
+
get footer() {
|
|
158
|
+
return this.data.footer ? (0, common_1.toCamelCase)(this.data.footer) : undefined;
|
|
159
|
+
}
|
|
160
|
+
get image() {
|
|
161
|
+
return this.data.image ? (0, common_1.toCamelCase)(this.data.image) : undefined;
|
|
162
|
+
}
|
|
163
|
+
get thumbnail() {
|
|
164
|
+
return this.data.thumbnail ? (0, common_1.toCamelCase)(this.data.thumbnail) : undefined;
|
|
165
|
+
}
|
|
166
|
+
get video() {
|
|
167
|
+
return this.data.video ? (0, common_1.toCamelCase)(this.data.video) : undefined;
|
|
168
|
+
}
|
|
169
|
+
get provider() {
|
|
170
|
+
return this.data.provider;
|
|
171
|
+
}
|
|
172
|
+
get author() {
|
|
173
|
+
return this.data.author ? (0, common_1.toCamelCase)(this.data.author) : undefined;
|
|
174
|
+
}
|
|
175
|
+
get fields() {
|
|
176
|
+
return this.data.fields;
|
|
177
|
+
}
|
|
178
|
+
toBuilder() {
|
|
179
|
+
return new __1.Embed(this.data);
|
|
180
|
+
}
|
|
181
|
+
toJSON() {
|
|
182
|
+
return { ...this.data };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.InMessageEmbed = InMessageEmbed;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { APISticker, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIGuildStickerFormDataBody } from 'discord-api-types/v10';
|
|
2
|
-
import type { UsingClient } from '..';
|
|
3
|
-
import type { Attachment } from '../builders';
|
|
2
|
+
import type { RawFile, UsingClient } from '..';
|
|
3
|
+
import type { Attachment, AttachmentBuilder } from '../builders';
|
|
4
4
|
import type { MethodContext, ObjectToLower } from '../common';
|
|
5
5
|
import { User } from './User';
|
|
6
6
|
import { DiscordBase } from './extra/DiscordBase';
|
|
@@ -24,5 +24,5 @@ export declare class Sticker extends DiscordBase {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
export interface CreateStickerBodyRequest extends Omit<RESTPostAPIGuildStickerFormDataBody, 'file'> {
|
|
27
|
-
file: Attachment;
|
|
27
|
+
file: Attachment | AttachmentBuilder | RawFile;
|
|
28
28
|
}
|
package/lib/structures/User.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class User extends DiscordBase<APIUser> {
|
|
|
16
16
|
*/
|
|
17
17
|
dm(force?: boolean): Promise<import("./channels").DMChannel>;
|
|
18
18
|
write(body: MessageCreateBodyRequest): Promise<import("./Message").Message>;
|
|
19
|
+
defaultAvatarURL(): string;
|
|
19
20
|
avatarURL(options?: ImageOptions): string;
|
|
20
21
|
avatarDecorationURL(options?: ImageOptions): string | undefined;
|
|
21
22
|
bannerURL(options?: ImageOptions): string | undefined;
|
package/lib/structures/User.js
CHANGED
|
@@ -25,9 +25,12 @@ class User extends DiscordBase_1.DiscordBase {
|
|
|
25
25
|
write(body) {
|
|
26
26
|
return this.client.users.write(this.id, body);
|
|
27
27
|
}
|
|
28
|
+
defaultAvatarURL() {
|
|
29
|
+
return this.rest.cdn.embed.avatars.get((0, api_1.calculateUserDefaultAvatarIndex)(this.id, this.discriminator));
|
|
30
|
+
}
|
|
28
31
|
avatarURL(options) {
|
|
29
32
|
if (!this.avatar) {
|
|
30
|
-
return this.
|
|
33
|
+
return this.defaultAvatarURL();
|
|
31
34
|
}
|
|
32
35
|
return this.rest.cdn.avatars(this.id).get(this.avatar, options);
|
|
33
36
|
}
|
|
@@ -4,6 +4,7 @@ import type { EmojiResolvable, MessageCreateBodyRequest, MessageUpdateBodyReques
|
|
|
4
4
|
import type { GuildMember } from './GuildMember';
|
|
5
5
|
import type { GuildRole } from './GuildRole';
|
|
6
6
|
import { DiscordBase } from './extra/DiscordBase';
|
|
7
|
+
import { Collection, type RawFile } from '..';
|
|
7
8
|
export declare class BaseChannel<T extends ChannelType> extends DiscordBase<APIChannelBase<ChannelType>> {
|
|
8
9
|
type: T;
|
|
9
10
|
constructor(client: UsingClient, data: APIChannelBase<ChannelType>);
|
|
@@ -153,7 +154,7 @@ export declare class MessagesMethods extends DiscordBase {
|
|
|
153
154
|
set: (messageId: string, reason?: string) => Promise<never>;
|
|
154
155
|
delete: (messageId: string, reason?: string) => Promise<never>;
|
|
155
156
|
};
|
|
156
|
-
static transformMessageBody<T>(body: MessageCreateBodyRequest | MessageUpdateBodyRequest, self: UsingClient): T;
|
|
157
|
+
static transformMessageBody<T>(body: MessageCreateBodyRequest | MessageUpdateBodyRequest, files: RawFile[] | undefined, self: UsingClient): T;
|
|
157
158
|
}
|
|
158
159
|
export interface TextBaseGuildChannel extends ObjectToLower<Omit<APITextChannel, 'type' | 'permission_overwrites'>>, MessagesMethods {
|
|
159
160
|
}
|
|
@@ -185,6 +186,7 @@ export declare class VoiceChannelMethods extends DiscordBase {
|
|
|
185
186
|
setVideoQuality(quality: keyof typeof VideoQualityMode, reason?: string): Promise<AllChannels>;
|
|
186
187
|
setVoiceState(status?: string | null): Promise<never>;
|
|
187
188
|
states(): Promise<import("./VoiceState").VoiceState[]>;
|
|
189
|
+
members(force?: boolean): Promise<Collection<string, GuildMember>>;
|
|
188
190
|
}
|
|
189
191
|
export declare class WebhookGuildMethods extends DiscordBase {
|
|
190
192
|
webhooks: {
|
|
@@ -277,5 +279,6 @@ export declare class DirectoryChannel extends BaseChannel<ChannelType.GuildDirec
|
|
|
277
279
|
export type AllGuildChannels = TextGuildChannel | VoiceChannel | MediaChannel | ForumChannel | ThreadChannel | CategoryChannel | NewsChannel | DirectoryChannel | StageChannel;
|
|
278
280
|
export type AllTextableChannels = TextGuildChannel | VoiceChannel | DMChannel | NewsChannel | ThreadChannel;
|
|
279
281
|
export type AllGuildTextableChannels = TextGuildChannel | VoiceChannel | NewsChannel | ThreadChannel;
|
|
282
|
+
export type AllGuildVoiceChannels = VoiceChannel | StageChannel;
|
|
280
283
|
export type AllChannels = BaseChannel<ChannelType> | BaseGuildChannel | TextGuildChannel | DMChannel | VoiceChannel | MediaChannel | ForumChannel | ThreadChannel | CategoryChannel | NewsChannel | DirectoryChannel | StageChannel;
|
|
281
284
|
export {};
|
|
@@ -12,6 +12,7 @@ const ts_mixer_1 = require("ts-mixer");
|
|
|
12
12
|
const builders_1 = require("../builders");
|
|
13
13
|
const DiscordBase_1 = require("./extra/DiscordBase");
|
|
14
14
|
const functions_1 = require("./extra/functions");
|
|
15
|
+
const __1 = require("..");
|
|
15
16
|
class BaseChannel extends DiscordBase_1.DiscordBase {
|
|
16
17
|
constructor(client, data) {
|
|
17
18
|
super(client, data);
|
|
@@ -131,9 +132,15 @@ class MessagesMethods extends DiscordBase_1.DiscordBase {
|
|
|
131
132
|
typing() {
|
|
132
133
|
return this.client.channels.typing(this.id);
|
|
133
134
|
}
|
|
134
|
-
messages = MessagesMethods.messages({
|
|
135
|
+
messages = MessagesMethods.messages({
|
|
136
|
+
client: this.client,
|
|
137
|
+
channelId: this.id,
|
|
138
|
+
});
|
|
135
139
|
pins = MessagesMethods.pins({ client: this.client, channelId: this.id });
|
|
136
|
-
reactions = MessagesMethods.reactions({
|
|
140
|
+
reactions = MessagesMethods.reactions({
|
|
141
|
+
client: this.client,
|
|
142
|
+
channelId: this.id,
|
|
143
|
+
});
|
|
137
144
|
static messages(ctx) {
|
|
138
145
|
return {
|
|
139
146
|
write: (body) => ctx.client.messages.write(ctx.channelId, body),
|
|
@@ -159,14 +166,22 @@ class MessagesMethods extends DiscordBase_1.DiscordBase {
|
|
|
159
166
|
delete: (messageId, reason) => ctx.client.channels.deletePin(messageId, ctx.channelId, reason),
|
|
160
167
|
};
|
|
161
168
|
}
|
|
162
|
-
static transformMessageBody(body, self) {
|
|
169
|
+
static transformMessageBody(body, files, self) {
|
|
163
170
|
const poll = body.poll;
|
|
164
171
|
return {
|
|
165
172
|
allowed_mentions: self.options?.allowedMentions,
|
|
166
173
|
...body,
|
|
167
174
|
components: body.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)) ?? undefined,
|
|
168
175
|
embeds: body.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)) ?? undefined,
|
|
169
|
-
attachments:
|
|
176
|
+
attachments: 'attachments' in body
|
|
177
|
+
? body.attachments?.map((x, i) => ({
|
|
178
|
+
id: i,
|
|
179
|
+
...(0, builders_1.resolveAttachment)(x),
|
|
180
|
+
})) ?? undefined
|
|
181
|
+
: files?.map((x, id) => ({
|
|
182
|
+
id,
|
|
183
|
+
filename: x.name,
|
|
184
|
+
})),
|
|
170
185
|
poll: poll ? (poll instanceof builders_1.PollBuilder ? poll.toJSON() : poll) : undefined,
|
|
171
186
|
};
|
|
172
187
|
}
|
|
@@ -266,10 +281,22 @@ class VoiceChannelMethods extends DiscordBase_1.DiscordBase {
|
|
|
266
281
|
const filter = states.filter(state => state.channelId === this.id);
|
|
267
282
|
return filter;
|
|
268
283
|
}
|
|
284
|
+
async members(force) {
|
|
285
|
+
const collection = new __1.Collection();
|
|
286
|
+
const states = await this.states();
|
|
287
|
+
for (const state of states) {
|
|
288
|
+
const member = await state.member(force);
|
|
289
|
+
collection.set(member.id, member);
|
|
290
|
+
}
|
|
291
|
+
return collection;
|
|
292
|
+
}
|
|
269
293
|
}
|
|
270
294
|
exports.VoiceChannelMethods = VoiceChannelMethods;
|
|
271
295
|
class WebhookGuildMethods extends DiscordBase_1.DiscordBase {
|
|
272
|
-
webhooks = WebhookGuildMethods.guild({
|
|
296
|
+
webhooks = WebhookGuildMethods.guild({
|
|
297
|
+
client: this.client,
|
|
298
|
+
guildId: this.id,
|
|
299
|
+
});
|
|
273
300
|
static guild(ctx) {
|
|
274
301
|
return {
|
|
275
302
|
list: () => ctx.client.webhooks.listFromGuild(ctx.guildId),
|
|
@@ -278,7 +305,10 @@ class WebhookGuildMethods extends DiscordBase_1.DiscordBase {
|
|
|
278
305
|
}
|
|
279
306
|
exports.WebhookGuildMethods = WebhookGuildMethods;
|
|
280
307
|
class WebhookChannelMethods extends DiscordBase_1.DiscordBase {
|
|
281
|
-
webhooks = WebhookChannelMethods.channel({
|
|
308
|
+
webhooks = WebhookChannelMethods.channel({
|
|
309
|
+
client: this.client,
|
|
310
|
+
channelId: this.id,
|
|
311
|
+
});
|
|
282
312
|
static channel(ctx) {
|
|
283
313
|
return {
|
|
284
314
|
list: () => ctx.client.webhooks.listFromChannel(ctx.channelId),
|
|
@@ -25,7 +25,7 @@ function resolvePartialEmoji(emoji) {
|
|
|
25
25
|
if (emoji.includes('%')) {
|
|
26
26
|
emoji = encodeURIComponent(emoji);
|
|
27
27
|
}
|
|
28
|
-
if (!emoji.includes(':')
|
|
28
|
+
if (!(emoji.includes(':') || emoji.match(/\d{17,20}/g))) {
|
|
29
29
|
return { name: emoji, id: null };
|
|
30
30
|
}
|
|
31
31
|
return;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.BaseSocket = void 0;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
8
|
const ws_1 = __importDefault(require("ws"));
|
|
8
9
|
class BaseSocket {
|
|
9
10
|
internal;
|
|
@@ -29,6 +30,22 @@ class BaseSocket {
|
|
|
29
30
|
// @ts-expect-error
|
|
30
31
|
return this.internal.close(...args);
|
|
31
32
|
}
|
|
33
|
+
async ping() {
|
|
34
|
+
if (!('ping' in this.internal))
|
|
35
|
+
throw new Error('Unexpected: Method ping not implemented');
|
|
36
|
+
return new Promise(res => {
|
|
37
|
+
const nonce = (0, node_crypto_1.randomUUID)();
|
|
38
|
+
const start = performance.now();
|
|
39
|
+
const listener = (data) => {
|
|
40
|
+
if (data.toString() !== nonce)
|
|
41
|
+
return;
|
|
42
|
+
this.internal.removeListener('pong', listener);
|
|
43
|
+
res(performance.now() - start);
|
|
44
|
+
};
|
|
45
|
+
this.internal.on('pong', listener);
|
|
46
|
+
this.internal.ping(nonce);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
32
49
|
get readyState() {
|
|
33
50
|
return this.internal.readyState;
|
|
34
51
|
}
|
|
@@ -30,6 +30,7 @@ export declare class Shard {
|
|
|
30
30
|
get gatewayURL(): string;
|
|
31
31
|
get resumeGatewayURL(): string | undefined;
|
|
32
32
|
get currentGatewayURL(): string;
|
|
33
|
+
ping(): Promise<number>;
|
|
33
34
|
connect(): Promise<void>;
|
|
34
35
|
send<T extends GatewaySendPayload = GatewaySendPayload>(force: boolean, message: T): Promise<void>;
|
|
35
36
|
identify(): Promise<void>;
|
|
@@ -55,6 +55,11 @@ class Shard {
|
|
|
55
55
|
url.searchParams.set('v', '10');
|
|
56
56
|
return url.href;
|
|
57
57
|
}
|
|
58
|
+
ping() {
|
|
59
|
+
if (!this.websocket)
|
|
60
|
+
return Promise.resolve(Number.POSITIVE_INFINITY);
|
|
61
|
+
return this.websocket.ping();
|
|
62
|
+
}
|
|
58
63
|
async connect() {
|
|
59
64
|
await this.connectTimeout.wait();
|
|
60
65
|
if (this.isOpen) {
|
|
@@ -63,6 +68,7 @@ class Shard {
|
|
|
63
68
|
}
|
|
64
69
|
this.debugger?.debug(`[Shard #${this.id}] Connecting to ${this.currentGatewayURL}`);
|
|
65
70
|
// @ts-expect-error @types/bun cause erros in compile
|
|
71
|
+
// biome-ignore lint/correctness/noUndeclaredVariables: /\ bun lol
|
|
66
72
|
this.websocket = new basesocket_1.BaseSocket(typeof Bun === 'undefined' ? 'ws' : 'bun', this.currentGatewayURL);
|
|
67
73
|
this.websocket.onmessage = (event) => this.handleMessage(event);
|
|
68
74
|
this.websocket.onclose = (event) => this.handleClosed(event);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seyfert",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "The most advanced framework for discord bots",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"chokidar": "^3.6.0",
|
|
24
|
-
"discord-api-types": "^0.37.
|
|
24
|
+
"discord-api-types": "^0.37.86",
|
|
25
25
|
"magic-bytes.js": "^1.10.0",
|
|
26
26
|
"ts-mixer": "^6.0.4",
|
|
27
|
-
"ws": "^8.
|
|
27
|
+
"ws": "^8.17.0"
|
|
28
28
|
},
|
|
29
29
|
"lint-staged": {
|
|
30
30
|
"*.ts": [
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@biomejs/biome": "1.
|
|
37
|
-
"@commitlint/cli": "^19.
|
|
36
|
+
"@biomejs/biome": "1.7.3",
|
|
37
|
+
"@commitlint/cli": "^19.3.0",
|
|
38
38
|
"@commitlint/config-conventional": "^19.2.2",
|
|
39
|
-
"@types/node": "^20.12.
|
|
39
|
+
"@types/node": "^20.12.12",
|
|
40
40
|
"@types/ws": "^8.5.10",
|
|
41
41
|
"husky": "^9.0.11",
|
|
42
|
-
"lint-staged": "^15.2.
|
|
42
|
+
"lint-staged": "^15.2.5",
|
|
43
43
|
"typescript": "^5.4.5"
|
|
44
44
|
},
|
|
45
45
|
"optionalDependencies": {
|
|
@@ -71,4 +71,4 @@
|
|
|
71
71
|
"url": "https://github.com/socram03"
|
|
72
72
|
}
|
|
73
73
|
]
|
|
74
|
-
}
|
|
74
|
+
}
|