seyfert 1.2.0 → 1.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.
Files changed (59) hide show
  1. package/lib/cache/index.d.ts +1 -5
  2. package/lib/cache/resources/voice-states.d.ts +7 -2
  3. package/lib/cache/resources/voice-states.js +11 -0
  4. package/lib/client/http/adapters/bun.d.ts +14 -0
  5. package/lib/client/http/adapters/bun.js +117 -0
  6. package/lib/client/http/adapters/index.d.ts +15 -0
  7. package/lib/client/http/adapters/index.js +27 -0
  8. package/lib/client/http/adapters/uws.d.ts +17 -0
  9. package/lib/client/http/adapters/uws.js +142 -0
  10. package/lib/client/http/httpclient.d.ts +13 -0
  11. package/lib/client/http/httpclient.js +48 -0
  12. package/lib/client/httpclient.js +31 -29
  13. package/lib/client/oninteractioncreate.js +7 -7
  14. package/lib/client/onmessagecreate.js +12 -3
  15. package/lib/client/workerclient.js +1 -1
  16. package/lib/commands/applications/chat.d.ts +11 -9
  17. package/lib/commands/applications/chat.js +9 -6
  18. package/lib/commands/applications/chatcontext.d.ts +2 -1
  19. package/lib/commands/applications/chatcontext.js +3 -0
  20. package/lib/commands/applications/menu.d.ts +4 -3
  21. package/lib/commands/applications/menu.js +9 -6
  22. package/lib/commands/applications/menucontext.d.ts +5 -2
  23. package/lib/commands/applications/menucontext.js +11 -2
  24. package/lib/commands/basecontex.d.ts +1 -1
  25. package/lib/commands/basecontex.js +5 -11
  26. package/lib/commands/decorators.d.ts +3 -3
  27. package/lib/commands/decorators.js +5 -5
  28. package/lib/commands/handler.js +2 -0
  29. package/lib/common/shorters/channels.d.ts +9 -2
  30. package/lib/common/shorters/channels.js +13 -0
  31. package/lib/common/shorters/members.d.ts +6 -0
  32. package/lib/common/shorters/members.js +6 -0
  33. package/lib/common/shorters/messages.d.ts +2 -2
  34. package/lib/common/shorters/messages.js +7 -3
  35. package/lib/components/componentcontext.d.ts +76 -4
  36. package/lib/components/componentcontext.js +68 -9
  37. package/lib/components/index.d.ts +1 -0
  38. package/lib/components/index.js +1 -0
  39. package/lib/structures/GuildMember.d.ts +1 -5
  40. package/lib/structures/GuildMember.js +2 -2
  41. package/lib/structures/Message.d.ts +1 -1
  42. package/lib/structures/User.js +3 -2
  43. package/lib/structures/VoiceState.d.ts +18 -0
  44. package/lib/structures/VoiceState.js +48 -0
  45. package/lib/structures/channels.d.ts +6 -3
  46. package/lib/structures/channels.js +14 -1
  47. package/lib/structures/extra/Permissions.d.ts +1 -1
  48. package/lib/structures/index.d.ts +1 -0
  49. package/lib/structures/index.js +1 -0
  50. package/lib/websocket/discord/shard.d.ts +4 -4
  51. package/lib/websocket/discord/shard.js +12 -17
  52. package/lib/websocket/discord/sharder.d.ts +1 -1
  53. package/lib/websocket/discord/sharder.js +2 -2
  54. package/lib/websocket/discord/workermanager.js +1 -1
  55. package/lib/websocket/structures/index.d.ts +6 -99
  56. package/lib/websocket/structures/index.js +29 -211
  57. package/lib/websocket/structures/timeout.d.ts +2 -2
  58. package/lib/websocket/structures/timeout.js +4 -4
  59. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { type APIApplicationCommandBasicOption, type APIApplicationCommandOption, ApplicationCommandOptionType, ApplicationCommandType, type LocaleString } from 'discord-api-types/v10';
1
+ import { ApplicationCommandOptionType, ApplicationCommandType, type APIApplicationCommandBasicOption, type APIApplicationCommandOption, type LocaleString } from 'discord-api-types/v10';
2
2
  import type { PermissionStrings, SeyfertNumberOption, SeyfertStringOption } from '../..';
3
3
  import type { Attachment } from '../../builders';
4
4
  import { type FlatObjectKeys } from '../../common';
@@ -77,13 +77,13 @@ declare class BaseCommand {
77
77
  description: string | undefined;
78
78
  defaultDescription: string;
79
79
  }>;
80
- guild_id?: string[];
80
+ guildId?: string[];
81
81
  name: string;
82
82
  type: number;
83
83
  nsfw?: boolean;
84
84
  description: string;
85
- default_member_permissions?: string;
86
- integration_types?: IntegrationTypes[];
85
+ defaultMemberPermissions?: bigint;
86
+ integrationTypes?: IntegrationTypes[];
87
87
  contexts?: InteractionContextTypes[];
88
88
  botPermissions?: bigint;
89
89
  name_localizations?: Partial<Record<LocaleString, string>>;
@@ -96,10 +96,10 @@ declare class BaseCommand {
96
96
  description: BaseCommand['description'];
97
97
  name_localizations: BaseCommand['name_localizations'];
98
98
  description_localizations: BaseCommand['description_localizations'];
99
- guild_id: BaseCommand['guild_id'];
100
- default_member_permissions: BaseCommand['default_member_permissions'];
99
+ guild_id: BaseCommand['guildId'];
100
+ default_member_permissions: string;
101
101
  contexts: BaseCommand['contexts'];
102
- integration_types: BaseCommand['integration_types'];
102
+ integration_types: BaseCommand['integrationTypes'];
103
103
  };
104
104
  reload(): Promise<void>;
105
105
  run?(context: CommandContext<any>): any;
@@ -107,6 +107,7 @@ declare class BaseCommand {
107
107
  onRunError?(context: CommandContext<any>, error: unknown): any;
108
108
  onOptionsError?(context: CommandContext<{}, never>, metadata: OnOptionsReturnObject): any;
109
109
  onMiddlewaresError?(context: CommandContext<{}, never>, error: string): any;
110
+ onBotPermissionsFail?(context: CommandContext<{}, never>, permissions: PermissionStrings): any;
110
111
  onPermissionsFail?(context: CommandContext<{}, never>, permissions: PermissionStrings): any;
111
112
  onInternalError?(client: UsingClient, error?: unknown): any;
112
113
  }
@@ -122,13 +123,14 @@ export declare class Command extends BaseCommand {
122
123
  name_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
123
124
  description_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
124
125
  guild_id: string[] | undefined;
125
- default_member_permissions: string | undefined;
126
+ default_member_permissions: string;
126
127
  contexts: InteractionContextTypes[] | undefined;
127
128
  integration_types: IntegrationTypes[] | undefined;
128
129
  };
129
130
  onRunError(context: CommandContext<any>, error: unknown): any;
130
131
  onOptionsError(context: CommandContext<{}, never>, metadata: OnOptionsReturnObject): any;
131
132
  onMiddlewaresError(context: CommandContext<{}, never>, error: string): any;
133
+ onBotPermissionsFail(context: CommandContext<{}, never>, permissions: PermissionStrings): any;
132
134
  onPermissionsFail(context: CommandContext<{}, never>, permissions: PermissionStrings): any;
133
135
  onInternalError(client: UsingClient, error?: unknown): any;
134
136
  }
@@ -145,7 +147,7 @@ export declare abstract class SubCommand extends BaseCommand {
145
147
  name_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
146
148
  description_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
147
149
  guild_id: string[] | undefined;
148
- default_member_permissions: string | undefined;
150
+ default_member_permissions: string;
149
151
  contexts: InteractionContextTypes[] | undefined;
150
152
  integration_types: IntegrationTypes[] | undefined;
151
153
  };
@@ -9,13 +9,13 @@ class BaseCommand {
9
9
  __t;
10
10
  __autoload;
11
11
  __tGroups;
12
- guild_id;
12
+ guildId;
13
13
  name;
14
14
  type; // ApplicationCommandType.ChatInput | ApplicationCommandOptionType.Subcommand
15
15
  nsfw;
16
16
  description;
17
- default_member_permissions;
18
- integration_types;
17
+ defaultMemberPermissions;
18
+ integrationTypes;
19
19
  contexts;
20
20
  botPermissions;
21
21
  name_localizations;
@@ -118,10 +118,10 @@ class BaseCommand {
118
118
  description: this.description,
119
119
  name_localizations: this.name_localizations,
120
120
  description_localizations: this.description_localizations,
121
- guild_id: this.guild_id,
122
- default_member_permissions: this.default_member_permissions,
121
+ guild_id: this.guildId,
122
+ default_member_permissions: this.defaultMemberPermissions ? this.defaultMemberPermissions.toString() : undefined,
123
123
  contexts: this.contexts,
124
- integration_types: this.integration_types,
124
+ integration_types: this.integrationTypes,
125
125
  };
126
126
  return data;
127
127
  }
@@ -177,6 +177,9 @@ class Command extends BaseCommand {
177
177
  onMiddlewaresError(context, error) {
178
178
  context.client.logger.fatal(`${this.name}.<onMiddlewaresError>`, context.author.id, error);
179
179
  }
180
+ onBotPermissionsFail(context, permissions) {
181
+ context.client.logger.fatal(`${this.name}.<onBotPermissionsFail>`, context.author.id, permissions);
182
+ }
180
183
  onPermissionsFail(context, permissions) {
181
184
  context.client.logger.fatal(`${this.name}.<onPermissionsFail>`, context.author.id, permissions);
182
185
  }
@@ -29,7 +29,7 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
29
29
  write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
30
30
  deferReply(ephemeral?: boolean): Promise<void | Message>;
31
31
  editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
32
- deleteResponse(): Promise<void | undefined>;
32
+ deleteResponse(): Promise<void>;
33
33
  editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
34
34
  fetchResponse(): Promise<If<InferWithPrefix, WebhookMessage | Message | undefined, WebhookMessage | undefined>>;
35
35
  channel(mode?: 'rest' | 'flow'): Promise<If<InferWithPrefix, AllChannels | undefined, AllChannels>>;
@@ -42,4 +42,5 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
42
42
  get channelId(): string;
43
43
  get author(): import("../..").User;
44
44
  get member(): If<InferWithPrefix, GuildMember | InteractionGuildMember | undefined, InteractionGuildMember | undefined>;
45
+ isChat(): this is CommandContext;
45
46
  }
@@ -122,5 +122,8 @@ class CommandContext extends basecontex_1.BaseContext {
122
122
  get member() {
123
123
  return this.interaction?.member || this.message?.member;
124
124
  }
125
+ isChat() {
126
+ return true;
127
+ }
125
128
  }
126
129
  exports.CommandContext = CommandContext;
@@ -10,14 +10,14 @@ export declare abstract class ContextMenuCommand {
10
10
  name: string | undefined;
11
11
  description: string | undefined;
12
12
  };
13
- guild_id?: string[];
13
+ guildId?: string[];
14
14
  name: string;
15
15
  type: ApplicationCommandType.User | ApplicationCommandType.Message;
16
16
  nsfw?: boolean;
17
- integration_types?: IntegrationTypes[];
17
+ integrationTypes?: IntegrationTypes[];
18
18
  contexts?: InteractionContextTypes[];
19
19
  description: string;
20
- default_member_permissions?: string;
20
+ defaultMemberPermissions?: bigint;
21
21
  botPermissions?: bigint;
22
22
  dm?: boolean;
23
23
  name_localizations?: Partial<Record<LocaleString, string>>;
@@ -40,6 +40,7 @@ export declare abstract class ContextMenuCommand {
40
40
  onAfterRun?(context: MenuCommandContext<any>, error: unknown | undefined): any;
41
41
  onRunError(context: MenuCommandContext<any, never>, error: unknown): any;
42
42
  onMiddlewaresError(context: MenuCommandContext<any, never>, error: string): any;
43
+ onBotPermissionsFail(context: MenuCommandContext<any, never>, permissions: PermissionStrings): any;
43
44
  onPermissionsFail(context: MenuCommandContext<any, never>, permissions: PermissionStrings): any;
44
45
  onInternalError(client: UsingClient, error?: unknown): any;
45
46
  }
@@ -6,14 +6,14 @@ class ContextMenuCommand {
6
6
  middlewares = [];
7
7
  __filePath;
8
8
  __t;
9
- guild_id;
9
+ guildId;
10
10
  name;
11
11
  type;
12
12
  nsfw;
13
- integration_types;
13
+ integrationTypes;
14
14
  contexts;
15
15
  description;
16
- default_member_permissions;
16
+ defaultMemberPermissions;
17
17
  botPermissions;
18
18
  dm;
19
19
  name_localizations;
@@ -74,11 +74,11 @@ class ContextMenuCommand {
74
74
  description: this.description,
75
75
  name_localizations: this.name_localizations,
76
76
  description_localizations: this.description_localizations,
77
- guild_id: this.guild_id,
77
+ guild_id: this.guildId,
78
78
  dm_permission: this.dm,
79
- default_member_permissions: this.default_member_permissions,
79
+ default_member_permissions: this.defaultMemberPermissions ? this.defaultMemberPermissions.toString() : undefined,
80
80
  contexts: this.contexts,
81
- integration_types: this.integration_types,
81
+ integration_types: this.integrationTypes,
82
82
  };
83
83
  }
84
84
  async reload() {
@@ -92,6 +92,9 @@ class ContextMenuCommand {
92
92
  onMiddlewaresError(context, error) {
93
93
  context.client.logger.fatal(`${this.name}.<onMiddlewaresError>`, context.author.id, error);
94
94
  }
95
+ onBotPermissionsFail(context, permissions) {
96
+ context.client.logger.fatal(`${this.name}.<onBotPermissionsFail>`, context.author.id, permissions);
97
+ }
95
98
  onPermissionsFail(context, permissions) {
96
99
  context.client.logger.fatal(`${this.name}.<onPermissionsFail>`, context.author.id, permissions);
97
100
  }
@@ -1,5 +1,5 @@
1
1
  import type { ContextMenuCommand, ReturnCache, WebhookMessage } from '../..';
2
- import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type UnionToTuple, type When } from '../../common';
2
+ import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type ModalCreateBodyRequest, type UnionToTuple, type When } from '../../common';
3
3
  import { Message, User, type AllChannels, type Guild, type GuildMember, type MessageCommandInteraction, type UserCommandInteraction } from '../../structures';
4
4
  import { BaseContext } from '../basecontex';
5
5
  import type { RegisteredMiddlewares } from '../decorators';
@@ -21,7 +21,7 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
21
21
  };
22
22
  get fullCommandName(): string;
23
23
  write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void | WebhookMessage>>;
24
- get modal(): ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>) | ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>);
24
+ modal(body: ModalCreateBodyRequest): Promise<void>;
25
25
  deferReply(ephemeral?: boolean): Promise<void>;
26
26
  editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
27
27
  deleteResponse(): Promise<void | undefined>;
@@ -37,4 +37,7 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
37
37
  get channelId(): string;
38
38
  get author(): User;
39
39
  get member(): import("../..").InteractionGuildMember | undefined;
40
+ isMenu(): this is MenuCommandContext<UserCommandInteraction | MessageCommandInteraction>;
41
+ isMenuUser(): this is MenuCommandContext<UserCommandInteraction>;
42
+ isMenuMessage(): this is MenuCommandContext<MessageCommandInteraction>;
40
43
  }
@@ -41,8 +41,8 @@ class MenuCommandContext extends basecontex_1.BaseContext {
41
41
  write(body, fetchReply) {
42
42
  return this.interaction.write(body, fetchReply);
43
43
  }
44
- get modal() {
45
- return this.interaction.modal;
44
+ modal(body) {
45
+ return this.interaction.modal(body);
46
46
  }
47
47
  deferReply(ephemeral = false) {
48
48
  return this.interaction.deferReply(ephemeral ? v10_1.MessageFlags.Ephemeral : undefined);
@@ -96,5 +96,14 @@ class MenuCommandContext extends basecontex_1.BaseContext {
96
96
  get member() {
97
97
  return this.interaction.member;
98
98
  }
99
+ isMenu() {
100
+ return true;
101
+ }
102
+ isMenuUser() {
103
+ return this.target instanceof structures_1.User;
104
+ }
105
+ isMenuMessage() {
106
+ return this.target instanceof structures_1.Message;
107
+ }
99
108
  }
100
109
  exports.MenuCommandContext = MenuCommandContext;
@@ -1,5 +1,5 @@
1
1
  import type { ComponentCommandInteractionMap, ComponentContext } from '../components/componentcontext';
2
- import { type MessageCommandInteraction, type UserCommandInteraction } from '../structures';
2
+ import type { MessageCommandInteraction, UserCommandInteraction } from '../structures';
3
3
  import type { CommandContext } from './applications/chatcontext';
4
4
  import type { MenuCommandContext } from './applications/menucontext';
5
5
  import type { UsingClient } from './applications/shared';
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseContext = void 0;
4
- const v10_1 = require("discord-api-types/v10");
5
- const structures_1 = require("../structures");
6
4
  class BaseContext {
7
5
  client;
8
6
  constructor(client) {
@@ -12,23 +10,19 @@ class BaseContext {
12
10
  return this.client.proxy;
13
11
  }
14
12
  isChat() {
15
- //@ts-expect-error
16
- return this.message || this.interaction.type === v10_1.ApplicationCommandType.ChatInput;
13
+ return false;
17
14
  }
18
15
  isMenu() {
19
- return this.isMenuUser() || this.isMenuMessage();
16
+ return false;
20
17
  }
21
18
  isMenuUser() {
22
- //@ts-expect-error
23
- return this.target instanceof structures_1.User;
19
+ return false;
24
20
  }
25
21
  isMenuMessage() {
26
- //@ts-expect-error
27
- return this.target instanceof structures_1.Message;
22
+ return false;
28
23
  }
29
24
  isComponent() {
30
- //@ts-expect-error
31
- return this.interaction.type === v10_1.InteractionType.MessageComponent;
25
+ return false;
32
26
  }
33
27
  }
34
28
  exports.BaseContext = BaseContext;
@@ -109,12 +109,12 @@ export declare function Declare(declare: DeclareOptions): <T extends new (...arg
109
109
  name: string;
110
110
  nsfw: boolean | undefined;
111
111
  contexts: InteractionContextTypes[] | undefined;
112
- integration_types: IntegrationTypes[] | undefined;
113
- default_member_permissions: string | bigint | undefined;
112
+ integrationTypes: IntegrationTypes[] | undefined;
113
+ defaultMemberPermissions: bigint | undefined;
114
114
  botPermissions: bigint | undefined;
115
115
  description: string;
116
116
  type: ApplicationCommandType;
117
- guild_id?: string[] | undefined;
117
+ guildId?: string[] | undefined;
118
118
  };
119
119
  } & T;
120
120
  export {};
@@ -74,16 +74,16 @@ function Declare(declare) {
74
74
  name = declare.name;
75
75
  nsfw = declare.nsfw;
76
76
  contexts = declare.contexts?.map(i => InteractionContextTypes[i]);
77
- integration_types = declare.integrationTypes?.map(i => IntegrationTypes[i]);
78
- default_member_permissions = Array.isArray(declare.defaultMemberPermissions)
79
- ? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0)).toString()
77
+ integrationTypes = declare.integrationTypes?.map(i => IntegrationTypes[i]);
78
+ defaultMemberPermissions = Array.isArray(declare.defaultMemberPermissions)
79
+ ? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0))
80
80
  : declare.defaultMemberPermissions;
81
81
  botPermissions = Array.isArray(declare.botPermissions)
82
82
  ? declare.botPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0))
83
83
  : declare.botPermissions;
84
84
  description = '';
85
85
  type = v10_1.ApplicationCommandType.ChatInput;
86
- guild_id;
86
+ guildId;
87
87
  constructor(...args) {
88
88
  super(...args);
89
89
  if ('description' in declare)
@@ -91,7 +91,7 @@ function Declare(declare) {
91
91
  if ('type' in declare)
92
92
  this.type = declare.type;
93
93
  if ('guildId' in declare)
94
- this.guild_id = declare.guildId;
94
+ this.guildId = declare.guildId;
95
95
  // check if all properties are valid
96
96
  }
97
97
  };
@@ -96,6 +96,8 @@ class CommandHandler extends common_1.BaseHandler {
96
96
  option.onInternalError =
97
97
  option.onInternalError?.bind(option) ?? commandInstance.onInternalError?.bind(commandInstance);
98
98
  option.onAfterRun = option.onAfterRun?.bind(option) ?? commandInstance.onAfterRun?.bind(commandInstance);
99
+ option.onBotPermissionsFail =
100
+ option.onBotPermissionsFail?.bind(option) ?? commandInstance.onBotPermissionsFail?.bind(commandInstance);
99
101
  option.onPermissionsFail =
100
102
  option.onPermissionsFail?.bind(option) ?? commandInstance.onPermissionsFail?.bind(commandInstance);
101
103
  }
@@ -1,6 +1,6 @@
1
- import { type RESTPatchAPIChannelJSONBody } from 'discord-api-types/v10';
1
+ import { type RESTPatchAPIChannelJSONBody, type RESTPostAPIChannelThreadsJSONBody, type RESTPostAPIGuildForumThreadsJSONBody } from 'discord-api-types/v10';
2
2
  import { Message, type GuildMember, type GuildRole } from '../../structures';
3
- import { type AllChannels } from '../../structures/channels';
3
+ import { type AllChannels, type ThreadChannel } from '../../structures/channels';
4
4
  import { PermissionsBitField } from '../../structures/extra/Permissions';
5
5
  import { BaseShorter } from './base';
6
6
  export declare class ChannelShorter extends BaseShorter {
@@ -49,6 +49,13 @@ export declare class ChannelShorter extends BaseShorter {
49
49
  * @returns A Promise that resolves when the message is successfully unpinned.
50
50
  */
51
51
  deletePin(messageId: string, channelId: string, reason?: string): Promise<never>;
52
+ /**
53
+ * Creates a new thread in the channel (only guild based channels).
54
+ * @param channelId The ID of the parent channel.
55
+ * @param reason The reason for unpinning the message.
56
+ * @returns A promise that resolves when the thread is succesfully created.
57
+ */
58
+ thread(channelId: string, body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody, reason?: string): Promise<ThreadChannel>;
52
59
  memberPermissions(channelId: string, member: GuildMember, checkAdmin?: boolean): Promise<PermissionsBitField>;
53
60
  overwritesFor(channelId: string, member: GuildMember): Promise<{
54
61
  everyone: {
@@ -84,6 +84,19 @@ class ChannelShorter extends base_1.BaseShorter {
84
84
  deletePin(messageId, channelId, reason) {
85
85
  return this.client.proxy.channels(channelId).pins(messageId).delete({ reason });
86
86
  }
87
+ /**
88
+ * Creates a new thread in the channel (only guild based channels).
89
+ * @param channelId The ID of the parent channel.
90
+ * @param reason The reason for unpinning the message.
91
+ * @returns A promise that resolves when the thread is succesfully created.
92
+ */
93
+ async thread(channelId, body, reason) {
94
+ return (this.client.proxy
95
+ .channels(channelId)
96
+ .threads.post({ body, reason })
97
+ // When testing this, discord returns the thread object, but in discord api types it does not.
98
+ .then(thread => (0, channels_1.default)(thread, this.client)));
99
+ }
87
100
  async memberPermissions(channelId, member, checkAdmin = true) {
88
101
  const permissions = await member.fetchPermissions();
89
102
  if (checkAdmin && permissions.has(v10_1.PermissionFlagsBits.Administrator)) {
@@ -91,4 +91,10 @@ export declare class MemberShorter extends BaseShorter {
91
91
  listRoles(guildId: string, memberId: string, force?: boolean): Promise<import("../../structures").GuildRole[]>;
92
92
  sortRoles(guildId: string, memberId: string, force?: boolean): Promise<import("../../structures").GuildRole[]>;
93
93
  permissions(guildId: string, memberId: string, force?: boolean): Promise<PermissionsBitField>;
94
+ presence(memberId: string): import("../..").ReturnCache<(Omit<import("discord-api-types/v10").GatewayPresenceUpdate, "user"> & {
95
+ id: string;
96
+ } & {
97
+ guild_id: string;
98
+ }) | undefined>;
99
+ voice(guildId: string, memberId: string): import("../..").ReturnCache<import("../../structures").VoiceState | undefined>;
94
100
  }
@@ -183,5 +183,11 @@ class MemberShorter extends base_1.BaseShorter {
183
183
  const roles = await this.listRoles(guildId, memberId, force);
184
184
  return new Permissions_1.PermissionsBitField(roles.map(x => BigInt(x.permissions.bits)));
185
185
  }
186
+ presence(memberId) {
187
+ return this.client.cache.presences?.get(memberId);
188
+ }
189
+ voice(guildId, memberId) {
190
+ return this.client.cache.voiceStates?.get(memberId, guildId);
191
+ }
186
192
  }
187
193
  exports.MemberShorter = MemberShorter;
@@ -1,12 +1,12 @@
1
1
  import type { RESTPostAPIChannelMessagesThreadsJSONBody } from 'discord-api-types/v10';
2
- import { Message, ThreadChannel } from '../../structures';
2
+ import { Message, type ThreadChannel } from '../../structures';
3
3
  import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../types/write';
4
4
  import { BaseShorter } from './base';
5
5
  export declare class MessageShorter extends BaseShorter {
6
6
  write(channelId: string, { files, ...body }: MessageCreateBodyRequest): Promise<Message>;
7
7
  edit(messageId: string, channelId: string, { files, ...body }: MessageUpdateBodyRequest): Promise<Message>;
8
8
  crosspost(messageId: string, channelId: string, reason?: string): Promise<Message>;
9
- delete(messageId: string, channelId: string, reason?: string): Promise<void | undefined>;
9
+ delete(messageId: string, channelId: string, reason?: string): Promise<void>;
10
10
  fetch(messageId: string, channelId: string): Promise<Message>;
11
11
  purge(messages: string[], channelId: string, reason?: string): Promise<never>;
12
12
  thread(channelId: string, messageId: string, options: RESTPostAPIChannelMessagesThreadsJSONBody & {
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.MessageShorter = void 0;
4
7
  const builders_1 = require("../../builders");
5
8
  const structures_1 = require("../../structures");
9
+ const channels_1 = __importDefault(require("../../structures/channels"));
6
10
  const base_1 = require("./base");
7
11
  class MessageShorter extends base_1.BaseShorter {
8
12
  async write(channelId, { files, ...body }) {
@@ -44,7 +48,7 @@ class MessageShorter extends base_1.BaseShorter {
44
48
  .messages(messageId)
45
49
  .delete({ reason })
46
50
  .then(() => {
47
- return this.client.components?.onMessageDelete(messageId);
51
+ void this.client.components?.onMessageDelete(messageId);
48
52
  });
49
53
  }
50
54
  fetch(messageId, channelId) {
@@ -57,13 +61,13 @@ class MessageShorter extends base_1.BaseShorter {
57
61
  purge(messages, channelId, reason) {
58
62
  return this.client.proxy.channels(channelId).messages['bulk-delete'].post({ body: { messages }, reason });
59
63
  }
60
- thread(channelId, messageId, options) {
64
+ async thread(channelId, messageId, options) {
61
65
  const { reason, ...body } = options;
62
66
  return this.client.proxy
63
67
  .channels(channelId)
64
68
  .messages(messageId)
65
69
  .threads.post({ body, reason })
66
- .then(x => new structures_1.ThreadChannel(this.client, x));
70
+ .then(thread => (0, channels_1.default)(thread, this.client));
67
71
  }
68
72
  }
69
73
  exports.MessageShorter = MessageShorter;
@@ -1,34 +1,106 @@
1
1
  import type { AllChannels, ButtonInteraction, ChannelSelectMenuInteraction, ComponentInteraction, Guild, GuildMember, MentionableSelectMenuInteraction, Message, ReturnCache, RoleSelectMenuInteraction, StringSelectMenuInteraction, UserSelectMenuInteraction, WebhookMessage } from '..';
2
2
  import type { ExtendContext, UsingClient } from '../commands';
3
3
  import { BaseContext } from '../commands/basecontex';
4
- import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, When } from '../common';
4
+ import type { ComponentInteractionMessageUpdate, InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, When } from '../common';
5
5
  export interface ComponentContext<Type extends keyof ComponentCommandInteractionMap> extends BaseContext, ExtendContext {
6
6
  }
7
+ /**
8
+ * Represents a context for interacting with components in a Discord bot.
9
+ * @template Type - The type of component interaction.
10
+ */
7
11
  export declare class ComponentContext<Type extends keyof ComponentCommandInteractionMap> extends BaseContext {
8
12
  readonly client: UsingClient;
9
13
  interaction: ComponentCommandInteractionMap[Type] | ComponentInteraction;
14
+ /**
15
+ * Creates a new instance of the ComponentContext class.
16
+ * @param client - The UsingClient instance.
17
+ * @param interaction - The component interaction object.
18
+ */
10
19
  constructor(client: UsingClient, interaction: ComponentCommandInteractionMap[Type] | ComponentInteraction);
20
+ /**
21
+ * Gets the proxy object.
22
+ */
11
23
  get proxy(): import("..").APIRoutes;
24
+ /**
25
+ * Gets the language object for the interaction's locale.
26
+ */
12
27
  get t(): import("..").__InternalParseLocale<import("..").DefaultLocale> & {
13
28
  get(locale?: string | undefined): import("..").DefaultLocale;
14
29
  };
30
+ /**
31
+ * Gets the custom ID of the interaction.
32
+ */
15
33
  get customId(): string;
16
- get write(): <FR extends boolean = false>(body: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps, fetchReply?: FR | undefined) => Promise<When<FR, WebhookMessage, void>>;
34
+ /**
35
+ * Writes a response to the interaction.
36
+ * @param body - The body of the response.
37
+ * @param fetchReply - Whether to fetch the reply or not.
38
+ */
39
+ write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void>>;
40
+ /**
41
+ * Defers the reply to the interaction.
42
+ * @param ephemeral - Whether the reply should be ephemeral or not.
43
+ */
17
44
  deferReply(ephemeral?: boolean): Promise<void>;
18
- get editResponse(): ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>);
19
- get update(): ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>);
45
+ /**
46
+ * Edits the response of the interaction.
47
+ * @param body - The updated body of the response.
48
+ */
49
+ editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
50
+ /**
51
+ * Updates the interaction with new data.
52
+ * @param body - The updated body of the interaction.
53
+ */
54
+ update(body: ComponentInteractionMessageUpdate): Promise<void>;
55
+ /**
56
+ * Edits the response or replies to the interaction.
57
+ * @param body - The body of the response or updated body of the interaction.
58
+ * @param fetchReply - Whether to fetch the reply or not.
59
+ */
20
60
  editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
61
+ /**
62
+ * Deletes the response of the interaction.
63
+ * @returns A promise that resolves when the response is deleted.
64
+ */
21
65
  deleteResponse(): Promise<void | undefined>;
66
+ /**
67
+ * Gets the channel of the interaction.
68
+ * @param mode - The mode to fetch the channel.
69
+ * @returns A promise that resolves to the channel.
70
+ */
22
71
  channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
23
72
  channel(mode?: 'cache'): ReturnCache<AllChannels>;
73
+ /**
74
+ * Gets the bot member in the guild of the interaction.
75
+ * @param mode - The mode to fetch the member.
76
+ * @returns A promise that resolves to the bot member.
77
+ */
24
78
  me(mode?: 'rest' | 'flow'): Promise<GuildMember>;
25
79
  me(mode?: 'cache'): ReturnCache<GuildMember | undefined>;
80
+ /**
81
+ * Gets the guild of the interaction.
82
+ * @param mode - The mode to fetch the guild.
83
+ * @returns A promise that resolves to the guild.
84
+ */
26
85
  guild(mode?: 'rest' | 'flow'): Promise<Guild<'cached' | 'api'> | undefined>;
27
86
  guild(mode?: 'cache'): ReturnCache<Guild<'cached'> | undefined>;
87
+ /**
88
+ * Gets the ID of the guild of the interaction.
89
+ */
28
90
  get guildId(): string | undefined;
91
+ /**
92
+ * Gets the ID of the channel of the interaction.
93
+ */
29
94
  get channelId(): string;
95
+ /**
96
+ * Gets the author of the interaction.
97
+ */
30
98
  get author(): import("..").User;
99
+ /**
100
+ * Gets the member of the interaction.
101
+ */
31
102
  get member(): import("..").InteractionGuildMember | undefined;
103
+ isComponent(): this is ComponentContext<keyof ComponentCommandInteractionMap>;
32
104
  }
33
105
  export interface ComponentCommandInteractionMap {
34
106
  ActionRow: never;