seyfert 1.2.1 → 1.2.3

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 (89) hide show
  1. package/LICENSE +190 -190
  2. package/README.md +46 -46
  3. package/lib/api/Router.d.ts +9 -0
  4. package/lib/api/Router.js +16 -8
  5. package/lib/api/Routes/cdn.d.ts +26 -15
  6. package/lib/api/api.d.ts +2 -3
  7. package/lib/api/api.js +4 -9
  8. package/lib/api/index.d.ts +0 -1
  9. package/lib/api/index.js +0 -1
  10. package/lib/builders/Modal.d.ts +4 -1
  11. package/lib/builders/Modal.js +4 -1
  12. package/lib/cache/adapters/default.d.ts +1 -0
  13. package/lib/cache/adapters/default.js +4 -0
  14. package/lib/cache/adapters/redis.d.ts +2 -0
  15. package/lib/cache/adapters/redis.js +17 -0
  16. package/lib/cache/adapters/types.d.ts +1 -0
  17. package/lib/cache/adapters/workeradapter.d.ts +1 -0
  18. package/lib/cache/adapters/workeradapter.js +6 -9
  19. package/lib/cache/index.d.ts +4 -6
  20. package/lib/cache/index.js +3 -0
  21. package/lib/cache/resources/overwrites.d.ts +2 -0
  22. package/lib/cache/resources/voice-states.d.ts +7 -2
  23. package/lib/cache/resources/voice-states.js +11 -0
  24. package/lib/client/base.d.ts +1 -1
  25. package/lib/client/base.js +8 -5
  26. package/lib/client/oninteractioncreate.js +7 -7
  27. package/lib/client/onmessagecreate.js +27 -15
  28. package/lib/client/workerclient.js +6 -12
  29. package/lib/commands/applications/chat.d.ts +20 -15
  30. package/lib/commands/applications/chat.js +13 -7
  31. package/lib/commands/applications/chatcontext.d.ts +2 -1
  32. package/lib/commands/applications/chatcontext.js +3 -0
  33. package/lib/commands/applications/menu.d.ts +4 -3
  34. package/lib/commands/applications/menu.js +9 -6
  35. package/lib/commands/applications/menucontext.d.ts +4 -1
  36. package/lib/commands/applications/menucontext.js +9 -0
  37. package/lib/commands/applications/shared.d.ts +4 -0
  38. package/lib/commands/applications/shared.js +6 -0
  39. package/lib/commands/basecontex.d.ts +1 -1
  40. package/lib/commands/basecontex.js +5 -11
  41. package/lib/commands/decorators.d.ts +14 -4
  42. package/lib/commands/decorators.js +29 -5
  43. package/lib/commands/handler.js +2 -0
  44. package/lib/common/shorters/channels.d.ts +12 -2
  45. package/lib/common/shorters/channels.js +16 -2
  46. package/lib/common/shorters/members.d.ts +6 -0
  47. package/lib/common/shorters/members.js +6 -0
  48. package/lib/common/shorters/messages.d.ts +2 -2
  49. package/lib/common/shorters/messages.js +7 -3
  50. package/lib/common/types/options.d.ts +2 -2
  51. package/lib/components/componentcontext.d.ts +1 -0
  52. package/lib/components/componentcontext.js +3 -0
  53. package/lib/structures/GuildEmoji.d.ts +2 -2
  54. package/lib/structures/GuildEmoji.js +1 -1
  55. package/lib/structures/GuildMember.d.ts +1 -5
  56. package/lib/structures/GuildMember.js +3 -3
  57. package/lib/structures/Message.d.ts +1 -1
  58. package/lib/structures/User.d.ts +2 -3
  59. package/lib/structures/User.js +9 -4
  60. package/lib/structures/VoiceState.d.ts +18 -0
  61. package/lib/structures/VoiceState.js +48 -0
  62. package/lib/structures/Webhook.js +1 -1
  63. package/lib/structures/channels.d.ts +11 -3
  64. package/lib/structures/channels.js +14 -1
  65. package/lib/structures/extra/BaseGuild.js +3 -3
  66. package/lib/structures/extra/Permissions.d.ts +1 -1
  67. package/lib/structures/index.d.ts +1 -0
  68. package/lib/structures/index.js +1 -0
  69. package/lib/websocket/discord/shard.d.ts +4 -4
  70. package/lib/websocket/discord/shard.js +12 -17
  71. package/lib/websocket/discord/sharder.d.ts +1 -1
  72. package/lib/websocket/discord/sharder.js +2 -2
  73. package/lib/websocket/discord/worker.d.ts +1 -1
  74. package/lib/websocket/discord/workermanager.js +4 -10
  75. package/lib/websocket/structures/index.d.ts +6 -99
  76. package/lib/websocket/structures/index.js +29 -211
  77. package/lib/websocket/structures/timeout.d.ts +2 -2
  78. package/lib/websocket/structures/timeout.js +13 -16
  79. package/package.json +2 -2
  80. package/lib/api/CDN.d.ts +0 -212
  81. package/lib/api/CDN.js +0 -228
  82. package/lib/common/shorters/overwrites.d.ts +0 -29
  83. package/lib/common/shorters/overwrites.js +0 -63
  84. package/lib/components/listener.d.ts +0 -11
  85. package/lib/components/listener.js +0 -17
  86. package/lib/structures/extra/BaseComponent.d.ts +0 -9
  87. package/lib/structures/extra/BaseComponent.js +0 -12
  88. package/lib/structures/extra/BaseSelectMenuComponent.d.ts +0 -9
  89. package/lib/structures/extra/BaseSelectMenuComponent.js +0 -13
@@ -8,19 +8,20 @@ class BaseCommand {
8
8
  __filePath;
9
9
  __t;
10
10
  __autoload;
11
- __tGroups;
12
- guild_id;
11
+ guildId;
13
12
  name;
14
13
  type; // ApplicationCommandType.ChatInput | ApplicationCommandOptionType.Subcommand
15
14
  nsfw;
16
15
  description;
17
- default_member_permissions;
18
- integration_types;
16
+ defaultMemberPermissions;
17
+ integrationTypes;
19
18
  contexts;
20
19
  botPermissions;
21
20
  name_localizations;
22
21
  description_localizations;
23
22
  options;
23
+ ignore;
24
+ aliases;
24
25
  /** @internal */
25
26
  async __runOptions(ctx, resolver) {
26
27
  if (!this?.options?.length) {
@@ -118,10 +119,10 @@ class BaseCommand {
118
119
  description: this.description,
119
120
  name_localizations: this.name_localizations,
120
121
  description_localizations: this.description_localizations,
121
- guild_id: this.guild_id,
122
- default_member_permissions: this.default_member_permissions,
122
+ guild_id: this.guildId,
123
+ default_member_permissions: this.defaultMemberPermissions ? this.defaultMemberPermissions.toString() : undefined,
123
124
  contexts: this.contexts,
124
- integration_types: this.integration_types,
125
+ integration_types: this.integrationTypes,
125
126
  };
126
127
  return data;
127
128
  }
@@ -139,6 +140,8 @@ class BaseCommand {
139
140
  class Command extends BaseCommand {
140
141
  type = v10_1.ApplicationCommandType.ChatInput;
141
142
  groups;
143
+ groupsAliases;
144
+ __tGroups;
142
145
  toJSON() {
143
146
  const options = [];
144
147
  for (const i of this.options ?? []) {
@@ -177,6 +180,9 @@ class Command extends BaseCommand {
177
180
  onMiddlewaresError(context, error) {
178
181
  context.client.logger.fatal(`${this.name}.<onMiddlewaresError>`, context.author.id, error);
179
182
  }
183
+ onBotPermissionsFail(context, permissions) {
184
+ context.client.logger.fatal(`${this.name}.<onBotPermissionsFail>`, context.author.id, permissions);
185
+ }
180
186
  onPermissionsFail(context, permissions) {
181
187
  context.client.logger.fatal(`${this.name}.<onPermissionsFail>`, context.author.id, permissions);
182
188
  }
@@ -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, type ModalCreateBodyRequest } 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';
@@ -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
  }
@@ -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;
@@ -39,3 +39,7 @@ export type OnOptionsReturnObject = Record<string, {
39
39
  failed: true;
40
40
  value: string;
41
41
  }>;
42
+ export declare enum IgnoreCommand {
43
+ Slash = 0,
44
+ Message = 1
45
+ }
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IgnoreCommand = void 0;
4
+ var IgnoreCommand;
5
+ (function (IgnoreCommand) {
6
+ IgnoreCommand[IgnoreCommand["Slash"] = 0] = "Slash";
7
+ IgnoreCommand[IgnoreCommand["Message"] = 1] = "Message";
8
+ })(IgnoreCommand || (exports.IgnoreCommand = IgnoreCommand = {}));
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import { ApplicationCommandType, type LocaleString } from 'discord-api-types/v10';
2
2
  import type { FlatObjectKeys, PermissionStrings } from '../common';
3
3
  import type { CommandOption, OptionsRecord, SubCommand } from './applications/chat';
4
- import type { DefaultLocale, MiddlewareContext } from './applications/shared';
4
+ import type { DefaultLocale, IgnoreCommand, MiddlewareContext } from './applications/shared';
5
5
  export interface RegisteredMiddlewares {
6
6
  }
7
7
  export declare enum IntegrationTypes {
@@ -22,6 +22,8 @@ type DeclareOptions = {
22
22
  nsfw?: boolean;
23
23
  integrationTypes?: (keyof typeof IntegrationTypes)[];
24
24
  contexts?: (keyof typeof InteractionContextTypes)[];
25
+ ignore?: IgnoreCommand;
26
+ aliases?: string[];
25
27
  } | (Omit<{
26
28
  name: string;
27
29
  description: string;
@@ -59,26 +61,32 @@ export declare function GroupsT(groups: Record<string, {
59
61
  name?: FlatObjectKeys<DefaultLocale>;
60
62
  description?: FlatObjectKeys<DefaultLocale>;
61
63
  defaultDescription: string;
64
+ aliases?: string[];
62
65
  }>): <T extends new (...args: any[]) => {}>(target: T) => {
63
66
  new (...args: any[]): {
64
67
  __tGroups: Record<string, {
65
68
  name?: undefined;
66
69
  description?: undefined;
67
70
  defaultDescription: string;
71
+ aliases?: string[] | undefined;
68
72
  }>;
73
+ groupsAliases: Record<string, string>;
69
74
  };
70
75
  } & T;
71
76
  export declare function Groups(groups: Record<string, {
72
77
  name?: [language: LocaleString, value: string][];
73
78
  description?: [language: LocaleString, value: string][];
74
79
  defaultDescription: string;
80
+ aliases?: string[];
75
81
  }>): <T extends new (...args: any[]) => {}>(target: T) => {
76
82
  new (...args: any[]): {
77
83
  groups: Record<string, {
78
84
  name?: [language: "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", value: string][] | undefined;
79
85
  description?: [language: "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", value: string][] | undefined;
80
86
  defaultDescription: string;
87
+ aliases?: string[] | undefined;
81
88
  }>;
89
+ groupsAliases: Record<string, string>;
82
90
  };
83
91
  } & T;
84
92
  export declare function Group(groupName: string): <T extends new (...args: any[]) => {}>(target: T) => {
@@ -109,12 +117,14 @@ export declare function Declare(declare: DeclareOptions): <T extends new (...arg
109
117
  name: string;
110
118
  nsfw: boolean | undefined;
111
119
  contexts: InteractionContextTypes[] | undefined;
112
- integration_types: IntegrationTypes[] | undefined;
113
- default_member_permissions: string | bigint | undefined;
120
+ integrationTypes: IntegrationTypes[] | undefined;
121
+ defaultMemberPermissions: bigint | undefined;
114
122
  botPermissions: bigint | undefined;
115
123
  description: string;
116
124
  type: ApplicationCommandType;
117
- guild_id?: string[] | undefined;
125
+ guildId?: string[] | undefined;
126
+ ignore?: IgnoreCommand | undefined;
127
+ aliases?: string[] | undefined;
118
128
  };
119
129
  } & T;
120
130
  export {};
@@ -29,12 +29,30 @@ exports.LocalesT = LocalesT;
29
29
  function GroupsT(groups) {
30
30
  return (target) => class extends target {
31
31
  __tGroups = groups;
32
+ groupsAliases = {};
33
+ constructor(...args) {
34
+ super(...args);
35
+ for (const i in groups) {
36
+ for (const j of groups[i].aliases ?? []) {
37
+ this.groupsAliases[j] = i;
38
+ }
39
+ }
40
+ }
32
41
  };
33
42
  }
34
43
  exports.GroupsT = GroupsT;
35
44
  function Groups(groups) {
36
45
  return (target) => class extends target {
37
46
  groups = groups;
47
+ groupsAliases = {};
48
+ constructor(...args) {
49
+ super(...args);
50
+ for (const i in groups) {
51
+ for (const j of groups[i].aliases ?? []) {
52
+ this.groupsAliases[j] = i;
53
+ }
54
+ }
55
+ }
38
56
  };
39
57
  }
40
58
  exports.Groups = Groups;
@@ -74,16 +92,18 @@ function Declare(declare) {
74
92
  name = declare.name;
75
93
  nsfw = declare.nsfw;
76
94
  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()
95
+ integrationTypes = declare.integrationTypes?.map(i => IntegrationTypes[i]);
96
+ defaultMemberPermissions = Array.isArray(declare.defaultMemberPermissions)
97
+ ? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0))
80
98
  : declare.defaultMemberPermissions;
81
99
  botPermissions = Array.isArray(declare.botPermissions)
82
100
  ? declare.botPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0))
83
101
  : declare.botPermissions;
84
102
  description = '';
85
103
  type = v10_1.ApplicationCommandType.ChatInput;
86
- guild_id;
104
+ guildId;
105
+ ignore;
106
+ aliases;
87
107
  constructor(...args) {
88
108
  super(...args);
89
109
  if ('description' in declare)
@@ -91,7 +111,11 @@ function Declare(declare) {
91
111
  if ('type' in declare)
92
112
  this.type = declare.type;
93
113
  if ('guildId' in declare)
94
- this.guild_id = declare.guildId;
114
+ this.guildId = declare.guildId;
115
+ if ('ignore' in declare)
116
+ this.ignore = declare.ignore;
117
+ if ('aliases' in declare)
118
+ this.aliases = declare.aliases;
95
119
  // check if all properties are valid
96
120
  }
97
121
  };
@@ -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: {
@@ -56,18 +63,21 @@ export declare class ChannelShorter extends BaseShorter {
56
63
  id: string;
57
64
  deny: PermissionsBitField;
58
65
  allow: PermissionsBitField;
66
+ guildId: string;
59
67
  } | undefined;
60
68
  roles: {
61
69
  type: number;
62
70
  id: string;
63
71
  deny: PermissionsBitField;
64
72
  allow: PermissionsBitField;
73
+ guildId: string;
65
74
  }[];
66
75
  member: {
67
76
  type: number;
68
77
  id: string;
69
78
  deny: PermissionsBitField;
70
79
  allow: PermissionsBitField;
80
+ guildId: string;
71
81
  } | undefined;
72
82
  }>;
73
83
  rolePermissions(channelId: string, role: GuildRole, checkAdmin?: boolean): Promise<PermissionsBitField>;
@@ -84,12 +84,26 @@ 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
- const permissions = await member.fetchPermissions();
89
- if (checkAdmin && permissions.has(v10_1.PermissionFlagsBits.Administrator)) {
101
+ const memberPermissions = await member.fetchPermissions();
102
+ if (checkAdmin && memberPermissions.has(v10_1.PermissionFlagsBits.Administrator)) {
90
103
  return new Permissions_1.PermissionsBitField(Permissions_1.PermissionsBitField.All);
91
104
  }
92
105
  const overwrites = await this.overwritesFor(channelId, member);
106
+ const permissions = new Permissions_1.PermissionsBitField(memberPermissions.bits);
93
107
  permissions.remove(overwrites.everyone?.deny.bits ?? 0n);
94
108
  permissions.add(overwrites.everyone?.allow.bits ?? 0n);
95
109
  permissions.remove(overwrites.roles.length > 0 ? overwrites.roles.map(role => role.deny.bits) : 0n);
@@ -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,7 +1,7 @@
1
1
  import type { Identify } from '..';
2
- import type { ImageURLOptions } from '../../api';
2
+ import type { CDNUrlOptions } from '../../api';
3
3
  import type { UsingClient } from '../../commands';
4
- export type ImageOptions = ImageURLOptions;
4
+ export type ImageOptions = CDNUrlOptions;
5
5
  export type MethodContext<T = {}> = Identify<{
6
6
  client: UsingClient;
7
7
  } & T>;
@@ -100,6 +100,7 @@ export declare class ComponentContext<Type extends keyof ComponentCommandInterac
100
100
  * Gets the member of the interaction.
101
101
  */
102
102
  get member(): import("..").InteractionGuildMember | undefined;
103
+ isComponent(): this is ComponentContext<keyof ComponentCommandInteractionMap>;
103
104
  }
104
105
  export interface ComponentCommandInteractionMap {
105
106
  ActionRow: never;
@@ -131,5 +131,8 @@ class ComponentContext extends basecontex_1.BaseContext {
131
131
  get member() {
132
132
  return this.interaction.member;
133
133
  }
134
+ isComponent() {
135
+ return true;
136
+ }
134
137
  }
135
138
  exports.ComponentContext = ComponentContext;
@@ -1,5 +1,5 @@
1
1
  import type { APIEmoji, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildEmojiJSONBody } from 'discord-api-types/v10';
2
- import type { BaseImageURLOptions } from '../api';
2
+ import type { BaseCDNUrlOptions } from '../api';
3
3
  import type { UsingClient } from '../commands';
4
4
  import type { EmojiShorter, MethodContext, ObjectToLower } from '../common';
5
5
  import { DiscordBase } from './extra/DiscordBase';
@@ -12,7 +12,7 @@ export declare class GuildEmoji extends DiscordBase {
12
12
  edit(body: RESTPatchAPIChannelJSONBody, reason?: string): Promise<GuildEmoji>;
13
13
  delete(reason?: string): Promise<void>;
14
14
  fetch(force?: boolean): Promise<GuildEmoji>;
15
- url(options?: BaseImageURLOptions): string;
15
+ url(options?: BaseCDNUrlOptions): string;
16
16
  toString(): string;
17
17
  toJSON(): {
18
18
  id: string;
@@ -23,7 +23,7 @@ class GuildEmoji extends DiscordBase_1.DiscordBase {
23
23
  return this.client.emojis.fetch(this.guildId, this.id, force);
24
24
  }
25
25
  url(options) {
26
- return this.rest.cdn.emoji(this.id, options);
26
+ return this.rest.cdn.emojis(this.id).get(options);
27
27
  }
28
28
  toString() {
29
29
  return `<${this.animated ? 'a' : ''}:${this.name}:${this.id}>`;
@@ -31,11 +31,7 @@ export declare class BaseGuildMember extends DiscordBase {
31
31
  } & {
32
32
  guild_id: string;
33
33
  }) | undefined>;
34
- voice(): import("..").ReturnCache<(Omit<import("discord-api-types/v10").GatewayVoiceState, "member"> & {
35
- guild_id: string;
36
- } & {
37
- guild_id: string;
38
- }) | undefined>;
34
+ voice(): import("..").ReturnCache<import("./VoiceState").VoiceState | undefined>;
39
35
  toString(): string;
40
36
  private patch;
41
37
  get roles(): {
@@ -34,10 +34,10 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
34
34
  return this.client.members.edit(this.guildId, this.id, body, reason);
35
35
  }
36
36
  presence() {
37
- return this.cache.presences?.get(this.id);
37
+ return this.client.members.presence(this.id);
38
38
  }
39
39
  voice() {
40
- return this.cache.voiceStates?.get(this.id, this.guildId);
40
+ return this.client.members.voice(this.guildId, this.id);
41
41
  }
42
42
  toString() {
43
43
  return `<@${this.id}>`;
@@ -127,7 +127,7 @@ class GuildMember extends BaseGuildMember {
127
127
  if (!this.avatar) {
128
128
  return this.user.avatarURL(options);
129
129
  }
130
- return this.rest.cdn.guildMemberAvatar(this.guildId, this.id, this.avatar, options);
130
+ return this.rest.cdn.guilds(this.guildId).users(this.id).avatars(this.avatar).get(options);
131
131
  }
132
132
  bannerURL(options) {
133
133
  return this.user.bannerURL(options);