fix: clean code & messages cache

This commit is contained in:
MARCROCK22 2024-04-22 18:27:36 -04:00
parent a60bd19937
commit ef0786775c
5 changed files with 20 additions and 131 deletions

View File

@ -61,19 +61,15 @@ import type { RestArguments } from '../api';
export interface ChannelRoutes { export interface ChannelRoutes {
channels(id: string): { channels(id: string): {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIChannelJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIChannelJSONBody>,
): Promise<RESTPatchAPIChannelResult>; ): Promise<RESTPatchAPIChannelResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelResult>;
users: (id: '@me') => { users: (id: '@me') => {
threads: { threads: {
archived: { archived: {
private: { private: {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadsArchivedQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadsArchivedQuery>,
): Promise<RESTGetAPIChannelUsersThreadsArchivedResult>; ): Promise<RESTGetAPIChannelUsersThreadsArchivedResult>;
@ -82,33 +78,26 @@ export interface ChannelRoutes {
}; };
}; };
'thread-members': { 'thread-members': {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadMembersQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadMembersQuery>,
): Promise<RESTGetAPIChannelThreadMembersResult>; ): Promise<RESTGetAPIChannelThreadMembersResult>;
( (
id: '@me', id: '@me',
): { ): {
//.
put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIChannelThreadMembersResult>; put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIChannelThreadMembersResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelThreadMembersResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelThreadMembersResult>;
}; };
( (
id: string, id: string,
): { ): {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadMemberQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadMemberQuery>,
): Promise<RESTGetAPIChannelThreadMemberResult>; ): Promise<RESTGetAPIChannelThreadMemberResult>;
//.
put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIChannelThreadMembersResult>; put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIChannelThreadMembersResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelThreadMembersResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelThreadMembersResult>;
}; };
}; };
threads: { threads: {
//.
post( post(
args: RestArguments< args: RestArguments<
ProxyRequestMethod.Post, ProxyRequestMethod.Post,
@ -117,13 +106,11 @@ export interface ChannelRoutes {
): Promise<RESTPostAPIChannelThreadsResult>; ): Promise<RESTPostAPIChannelThreadsResult>;
archived: { archived: {
public: { public: {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadsArchivedQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadsArchivedQuery>,
): Promise<RESTGetAPIChannelThreadsArchivedPublicResult>; ): Promise<RESTGetAPIChannelThreadsArchivedPublicResult>;
}; };
private: { private: {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadsArchivedQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadsArchivedQuery>,
): Promise<RESTGetAPIChannelThreadsArchivedPrivateResult>; ): Promise<RESTGetAPIChannelThreadsArchivedPrivateResult>;
@ -131,58 +118,45 @@ export interface ChannelRoutes {
}; };
}; };
recipients: (id: string) => { recipients: (id: string) => {
//.
put( put(
args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIChannelRecipientJSONBody>, args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIChannelRecipientJSONBody>,
): Promise<RESTPutAPIChannelRecipientResult>; ): Promise<RESTPutAPIChannelRecipientResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelRecipientResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelRecipientResult>;
}; };
pins: { pins: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelPinsResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelPinsResult>;
( (
id: string, id: string,
): { ): {
//.
put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIChannelPinResult>; put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIChannelPinResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelPinResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelPinResult>;
}; };
}; };
followers: { followers: {
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelFollowersJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelFollowersJSONBody>,
): Promise<RESTPostAPIChannelFollowersResult>; ): Promise<RESTPostAPIChannelFollowersResult>;
}; };
permissions: (id: string) => { permissions: (id: string) => {
//.
put( put(
args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIChannelPermissionJSONBody>, args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIChannelPermissionJSONBody>,
): Promise<RESTPutAPIChannelPermissionResult>; ): Promise<RESTPutAPIChannelPermissionResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelPermissionResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelPermissionResult>;
}; };
invites: { invites: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelInvitesResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelInvitesResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelInviteJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelInviteJSONBody>,
): Promise<RESTPostAPIChannelInviteResult>; ): Promise<RESTPostAPIChannelInviteResult>;
}; };
messages: { messages: {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelMessagesQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelMessagesQuery>,
): Promise<RESTGetAPIChannelMessagesResult>; ): Promise<RESTGetAPIChannelMessagesResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelMessageJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelMessageJSONBody>,
): Promise<RESTPostAPIChannelMessageResult>; ): Promise<RESTPostAPIChannelMessageResult>;
'bulk-delete': { 'bulk-delete': {
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelMessagesBulkDeleteJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelMessagesBulkDeleteJSONBody>,
): Promise<RESTPostAPIChannelMessagesBulkDeleteResult>; ): Promise<RESTPostAPIChannelMessagesBulkDeleteResult>;
@ -190,44 +164,34 @@ export interface ChannelRoutes {
( (
id: string, id: string,
): { ): {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelMessageResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelMessageResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIChannelMessageJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIChannelMessageJSONBody>,
): Promise<RESTPatchAPIChannelMessageResult>; ): Promise<RESTPatchAPIChannelMessageResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelMessageResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelMessageResult>;
threads: { threads: {
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelMessagesThreadsJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelMessagesThreadsJSONBody>,
): Promise<RESTPostAPIChannelMessagesThreadsResult>; ): Promise<RESTPostAPIChannelMessagesThreadsResult>;
}; };
crosspost: { crosspost: {
//.
post(args: RestArguments<ProxyRequestMethod.Post>): Promise<RESTPostAPIChannelMessageCrosspostResult>; post(args: RestArguments<ProxyRequestMethod.Post>): Promise<RESTPostAPIChannelMessageCrosspostResult>;
}; };
reactions: { reactions: {
//.
delete( delete(
args?: RestArguments<ProxyRequestMethod.Delete>, args?: RestArguments<ProxyRequestMethod.Delete>,
): Promise<RESTDeleteAPIChannelAllMessageReactionsResult>; ): Promise<RESTDeleteAPIChannelAllMessageReactionsResult>;
( (
emoji: string, emoji: string,
): { ): {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelMessageReactionUsersQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelMessageReactionUsersQuery>,
): Promise<RESTGetAPIChannelMessageReactionUsersResult>; ): Promise<RESTGetAPIChannelMessageReactionUsersResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelMessageReactionResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelMessageReactionResult>;
( (
id: '@me', id: '@me',
): { ): {
//.
put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIChannelMessageReactionResult>; put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIChannelMessageReactionResult>;
//.
delete( delete(
args?: RestArguments<ProxyRequestMethod.Delete>, args?: RestArguments<ProxyRequestMethod.Delete>,
): Promise<RESTDeleteAPIChannelMessageReactionResult>; ): Promise<RESTDeleteAPIChannelMessageReactionResult>;
@ -235,7 +199,6 @@ export interface ChannelRoutes {
( (
id: string, id: string,
): { ): {
//.
delete( delete(
args?: RestArguments<ProxyRequestMethod.Delete>, args?: RestArguments<ProxyRequestMethod.Delete>,
): Promise<RESTDeleteAPIChannelMessageReactionResult>; ): Promise<RESTDeleteAPIChannelMessageReactionResult>;
@ -245,13 +208,10 @@ export interface ChannelRoutes {
}; };
}; };
typing: { typing: {
//.
post(args?: RestArguments<ProxyRequestMethod.Post>): Promise<RESTPostAPIChannelTypingResult>; post(args?: RestArguments<ProxyRequestMethod.Post>): Promise<RESTPostAPIChannelTypingResult>;
}; };
webhooks: { webhooks: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWebhooksResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWebhooksResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelWebhookJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelWebhookJSONBody>,
): Promise<RESTPostAPIChannelWebhookResult>; ): Promise<RESTPostAPIChannelWebhookResult>;

View File

@ -118,12 +118,9 @@ import type { RawFile } from '../shared';
export interface GuildRoutes { export interface GuildRoutes {
guilds: { guilds: {
//.
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildsJSONBody>): Promise<RESTPostAPIGuildsResult>; post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildsJSONBody>): Promise<RESTPostAPIGuildsResult>;
templates(code: string): { templates(code: string): {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPITemplateResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPITemplateResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPITemplateCreateGuildJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPITemplateCreateGuildJSONBody>,
): Promise<RESTPostAPITemplateCreateGuildResult>; ): Promise<RESTPostAPITemplateCreateGuildResult>;
@ -131,71 +128,54 @@ export interface GuildRoutes {
( (
id: string, id: string,
): { ): {
//.
get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildQuery>): Promise<RESTGetAPIGuildResult>; get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildQuery>): Promise<RESTGetAPIGuildResult>;
//.
patch(args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildJSONBody>): Promise<RESTPatchAPIGuildResult>; patch(args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildJSONBody>): Promise<RESTPatchAPIGuildResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildResult>;
webhooks: { webhooks: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWebhooksResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWebhooksResult>;
}; };
preview: { preview: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildPreviewResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildPreviewResult>;
}; };
'audit-logs': { 'audit-logs': {
//.
get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIAuditLogQuery>): Promise<RESTGetAPIAuditLogResult>; get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIAuditLogQuery>): Promise<RESTGetAPIAuditLogResult>;
}; };
'auto-moderation': { 'auto-moderation': {
rules: { rules: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIAutoModerationRulesResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIAutoModerationRulesResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIAutoModerationRuleJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIAutoModerationRuleJSONBody>,
): Promise<RESTPostAPIAutoModerationRuleResult>; ): Promise<RESTPostAPIAutoModerationRuleResult>;
( (
id: string, id: string,
): { ): {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIAutoModerationRuleResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIAutoModerationRuleResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Post, RESTPatchAPIAutoModerationRuleJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPatchAPIAutoModerationRuleJSONBody>,
): Promise<RESTPatchAPIAutoModerationRuleResult>; ): Promise<RESTPatchAPIAutoModerationRuleResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIAutoModerationRuleResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIAutoModerationRuleResult>;
}; };
}; };
}; };
channels: { channels: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildChannelsResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildChannelsResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildChannelJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildChannelJSONBody>,
): Promise<RESTPostAPIGuildChannelResult>; ): Promise<RESTPostAPIGuildChannelResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildChannelPositionsJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildChannelPositionsJSONBody>,
): Promise<RESTPatchAPIGuildChannelPositionsResult>; ): Promise<RESTPatchAPIGuildChannelPositionsResult>;
}; };
members: { members: {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildMembersQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildMembersQuery>,
): Promise<RESTGetAPIGuildMembersResult>; ): Promise<RESTGetAPIGuildMembersResult>;
search: { search: {
//.
get( get(
args: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildMembersSearchQuery>, args: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildMembersSearchQuery>,
): Promise<RESTGetAPIGuildMembersSearchResult>; ): Promise<RESTGetAPIGuildMembersSearchResult>;
}; };
'@me': { '@me': {
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPICurrentGuildMemberJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPICurrentGuildMemberJSONBody>,
): Promise<RESTGetAPIGuildMemberResult>; ): Promise<RESTGetAPIGuildMemberResult>;
@ -203,133 +183,102 @@ export interface GuildRoutes {
( (
id: string, id: string,
): { ): {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildMemberResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildMemberResult>;
//.
put( put(
args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIGuildMemberJSONBody>, args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIGuildMemberJSONBody>,
): Promise<RESTPutAPIGuildMemberResult>; ): Promise<RESTPutAPIGuildMemberResult>;
//.
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildMemberJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildMemberJSONBody>,
): Promise<RESTPatchAPIGuildMemberResult>; ): Promise<RESTPatchAPIGuildMemberResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildMemberResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildMemberResult>;
roles(id: string): { roles(id: string): {
//.
put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIGuildMemberRoleResult>; put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIGuildMemberRoleResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildMemberRoleResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildMemberRoleResult>;
}; };
}; };
}; };
threads: { threads: {
active: { active: {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get>, args?: RestArguments<ProxyRequestMethod.Get>,
): Promise<Identify<RESTGetAPIGuildThreadsResult & { threads: Partial<APIThreadChannel> }>>; ): Promise<Identify<RESTGetAPIGuildThreadsResult & { threads: Partial<APIThreadChannel> }>>;
}; };
}; };
roles: { roles: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildRolesResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildRolesResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildRoleJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildRoleJSONBody>,
): Promise<RESTPostAPIGuildRoleResult>; ): Promise<RESTPostAPIGuildRoleResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildRolePositionsJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildRolePositionsJSONBody>,
): Promise<RESTPatchAPIGuildRolePositionsResult>; ): Promise<RESTPatchAPIGuildRolePositionsResult>;
( (
id: string, id: string,
): { ): {
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildRoleJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildRoleJSONBody>,
): Promise<RESTPatchAPIGuildRoleResult>; ): Promise<RESTPatchAPIGuildRoleResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildRoleResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildRoleResult>;
}; };
}; };
bans: { bans: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildBansQuery>): Promise<RESTGetAPIGuildBansResult>; get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildBansQuery>): Promise<RESTGetAPIGuildBansResult>;
( (
userId: string, userId: string,
): { ): {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildBanResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildBanResult>;
//.
put( put(
args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIGuildBanJSONBody>, args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIGuildBanJSONBody>,
): Promise<RESTPutAPIGuildBanResult>; ): Promise<RESTPutAPIGuildBanResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildBanResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildBanResult>;
}; };
}; };
mfa: { mfa: {
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildsMFAJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildsMFAJSONBody>,
): Promise<RESTPostAPIGuildsMFAResult>; ): Promise<RESTPostAPIGuildsMFAResult>;
}; };
prune: { prune: {
//.
get( get(
args: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildPruneCountQuery>, args: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildPruneCountQuery>,
): Promise<RESTGetAPIGuildPruneCountResult>; ): Promise<RESTGetAPIGuildPruneCountResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildPruneJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildPruneJSONBody>,
): Promise<RESTPostAPIGuildPruneResult>; ): Promise<RESTPostAPIGuildPruneResult>;
}; };
regions: { regions: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildVoiceRegionsResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildVoiceRegionsResult>;
}; };
invites: { invites: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildInvitesResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildInvitesResult>;
}; };
widget: { widget: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWidgetSettingsResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWidgetSettingsResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildWidgetSettingsJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildWidgetSettingsJSONBody>,
): Promise<RESTPatchAPIGuildWidgetSettingsResult>; ): Promise<RESTPatchAPIGuildWidgetSettingsResult>;
}; };
'widget.json': { 'widget.json': {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWidgetJSONResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWidgetJSONResult>;
}; };
'widget.png': { 'widget.png': {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildWidgetImageQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildWidgetImageQuery>,
): Promise<RESTGetAPIGuildWidgetImageResult>; ): Promise<RESTGetAPIGuildWidgetImageResult>;
}; };
integrations: { integrations: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildIntegrationsResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildIntegrationsResult>;
( (
id: string, id: string,
): { ): {
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildIntegrationResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildIntegrationResult>;
}; };
}; };
'vanity-url': { 'vanity-url': {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildVanityUrlResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildVanityUrlResult>;
}; };
'welcome-screen': { 'welcome-screen': {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWelcomeScreenResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWelcomeScreenResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildWelcomeScreenJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildWelcomeScreenJSONBody>,
): Promise<RESTPatchAPIGuildWelcomeScreenResult>; ): Promise<RESTPatchAPIGuildWelcomeScreenResult>;
@ -338,28 +287,22 @@ export interface GuildRoutes {
// get(args:RestArguments<ProxyRequestMethod.Get,boarding>); // get(args:RestArguments<ProxyRequestMethod.Get,boarding>);
// } // }
emojis: { emojis: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildEmojisResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildEmojisResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildEmojiJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildEmojiJSONBody>,
): Promise<RESTPostAPIGuildEmojiResult>; ): Promise<RESTPostAPIGuildEmojiResult>;
( (
id: string, id: string,
): { ): {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildEmojiResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildEmojiResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildEmojiJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildEmojiJSONBody>,
): Promise<RESTPatchAPIGuildEmojiResult>; ): Promise<RESTPatchAPIGuildEmojiResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildEmojiResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildEmojiResult>;
}; };
}; };
'voice-states': { 'voice-states': {
'@me': { '@me': {
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody>,
): Promise<RESTPatchAPIGuildVoiceStateCurrentMemberResult>; ): Promise<RESTPatchAPIGuildVoiceStateCurrentMemberResult>;
@ -367,16 +310,13 @@ export interface GuildRoutes {
( (
id: string, id: string,
): { ): {
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildVoiceStateUserJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildVoiceStateUserJSONBody>,
): Promise<RESTPatchAPIGuildVoiceStateUserResult>; ): Promise<RESTPatchAPIGuildVoiceStateUserResult>;
}; };
}; };
stickers: { stickers: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildStickersResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildStickersResult>;
//.
post( post(
args: RestArguments< args: RestArguments<
ProxyRequestMethod.Post, ProxyRequestMethod.Post,
@ -388,40 +328,31 @@ export interface GuildRoutes {
( (
id: string, id: string,
): { ): {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildStickerResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildStickerResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildStickerJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildStickerJSONBody>,
): Promise<RESTPatchAPIGuildStickerResult>; ): Promise<RESTPatchAPIGuildStickerResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildStickerResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildStickerResult>;
}; };
}; };
'scheduled-events': { 'scheduled-events': {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildScheduledEventsQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildScheduledEventsQuery>,
): Promise<RESTGetAPIGuildScheduledEventsResult>; ): Promise<RESTGetAPIGuildScheduledEventsResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildScheduledEventJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildScheduledEventJSONBody>,
): Promise<RESTPostAPIGuildScheduledEventResult>; ): Promise<RESTPostAPIGuildScheduledEventResult>;
( (
id: string, id: string,
): { ): {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildScheduledEventQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildScheduledEventQuery>,
): Promise<RESTGetAPIGuildScheduledEventResult>; ): Promise<RESTGetAPIGuildScheduledEventResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildScheduledEventJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildScheduledEventJSONBody>,
): Promise<RESTPatchAPIGuildScheduledEventResult>; ): Promise<RESTPatchAPIGuildScheduledEventResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildScheduledEventResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildScheduledEventResult>;
users: { users: {
//.
get( get(
args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildScheduledEventUsersQuery>, args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIGuildScheduledEventUsersQuery>,
): Promise<RESTGetAPIGuildScheduledEventUsersResult>; ): Promise<RESTGetAPIGuildScheduledEventUsersResult>;
@ -429,22 +360,17 @@ export interface GuildRoutes {
}; };
}; };
templates: { templates: {
//.
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildTemplatesResult>; get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildTemplatesResult>;
//.
post( post(
args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildTemplatesJSONBody>, args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildTemplatesJSONBody>,
): Promise<RESTPostAPIGuildTemplatesResult>; ): Promise<RESTPostAPIGuildTemplatesResult>;
( (
code: string, code: string,
): { ): {
//.
put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIGuildTemplateSyncResult>; put(args?: RestArguments<ProxyRequestMethod.Put>): Promise<RESTPutAPIGuildTemplateSyncResult>;
//.
patch( patch(
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildTemplateJSONBody>, args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildTemplateJSONBody>,
): Promise<RESTPatchAPIGuildTemplateResult>; ): Promise<RESTPatchAPIGuildTemplateResult>;
//.
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildTemplateResult>; delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildTemplateResult>;
}; };
}; };

View File

@ -14,14 +14,15 @@ export class Messages extends GuildRelatedResource {
override parse(data: any, _key: string, _channel_id: string) { override parse(data: any, _key: string, _channel_id: string) {
const { author, member, ...rest } = data; const { author, member, ...rest } = data;
rest.user_id = author.id; if (author?.id) rest.user_id = author.id;
return rest; return rest;
} }
override get(id: string): ReturnCache<Message | undefined> { override get(id: string): ReturnCache<Message | undefined> {
return fakePromise(super.get(id) as APIMessageResource).then(rawMessage => { return fakePromise(super.get(id) as APIMessageResource).then(rawMessage => {
const user = this.cache.users const user =
this.cache.users && rawMessage.user_id
? (this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id)) as APIUser | undefined) ? (this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id)) as APIUser | undefined)
: undefined; : undefined;
return user ? new Message(this.client, { ...rawMessage, author: user }) : undefined; return user ? new Message(this.client, { ...rawMessage, author: user }) : undefined;
@ -33,7 +34,8 @@ export class Messages extends GuildRelatedResource {
messages => messages =>
messages messages
.map(rawMessage => { .map(rawMessage => {
const user = this.cache.users const user =
this.cache.users && rawMessage.user_id
? (this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id)) as APIUser | undefined) ? (this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id)) as APIUser | undefined)
: undefined; : undefined;
return user ? new Message(this.client, { ...rawMessage, author: user }) : undefined; return user ? new Message(this.client, { ...rawMessage, author: user }) : undefined;
@ -44,8 +46,10 @@ export class Messages extends GuildRelatedResource {
override values(guild: string): ReturnCache<Message[]> { override values(guild: string): ReturnCache<Message[]> {
return fakePromise(super.values(guild) as APIMessageResource[]).then(messages => { return fakePromise(super.values(guild) as APIMessageResource[]).then(messages => {
const hashes: string[] = this.cache.users ? messages.map(x => this.cache.users!.hashId(x.user_id)) : []; const hashes: (string | undefined)[] = this.cache.users
return fakePromise(this.cache.adapter.get(hashes) as APIUser[]).then(users => { ? messages.map(x => (x.user_id ? this.cache.users!.hashId(x.user_id) : undefined))
: [];
return fakePromise(this.cache.adapter.get(hashes.filter(Boolean) as string[]) as APIUser[]).then(users => {
return messages return messages
.map(message => { .map(message => {
const user = users.find(user => user.id === message.user_id); const user = users.find(user => user.id === message.user_id);
@ -57,4 +61,4 @@ export class Messages extends GuildRelatedResource {
} }
} }
export type APIMessageResource = Omit<APIMessage, 'author'> & { user_id: string }; export type APIMessageResource = Omit<APIMessage, 'author'> & { user_id?: string };

View File

@ -38,7 +38,7 @@ import {
} from 'discord-api-types/v10'; } from 'discord-api-types/v10';
import { mix } from 'ts-mixer'; import { mix } from 'ts-mixer';
import type { RawFile } from '../api'; import type { RawFile } from '../api';
import { ActionRow, Embed, Modal, resolveAttachment, resolveFiles } from '../builders'; import { ActionRow, Embed, Modal, PollBuilder, resolveAttachment, resolveFiles } from '../builders';
import { OptionResolver, type ContextOptionsResolved, type UsingClient } from '../commands'; import { OptionResolver, type ContextOptionsResolved, type UsingClient } from '../commands';
import type { ObjectToLower, OmitInsert, ToClass, When } from '../common'; import type { ObjectToLower, OmitInsert, ToClass, When } from '../common';
import type { import type {
@ -132,7 +132,7 @@ export class BaseInteraction<
components: body.data?.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)) ?? undefined, components: body.data?.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)) ?? undefined,
embeds: body.data?.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)) ?? undefined, embeds: body.data?.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)) ?? undefined,
attachments: body.data?.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) })) ?? undefined, attachments: body.data?.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) })) ?? undefined,
poll: poll ? ('toJSON' in poll ? poll.toJSON() : poll) : undefined, poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined,
}, },
}; };
} }
@ -170,8 +170,7 @@ export class BaseInteraction<
...body, ...body,
components: body.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)) ?? undefined, components: body.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)) ?? undefined,
embeds: body?.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)) ?? undefined, embeds: body?.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)) ?? undefined,
poll: poll ? ('toJSON' in poll ? poll.toJSON() : poll) : undefined, poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined,
// attachments: body.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) })) ?? undefined,
} as T; } as T;
} }

View File

@ -25,7 +25,7 @@ import {
type ThreadAutoArchiveDuration, type ThreadAutoArchiveDuration,
} from 'discord-api-types/v10'; } from 'discord-api-types/v10';
import { mix } from 'ts-mixer'; import { mix } from 'ts-mixer';
import { Embed, resolveAttachment } from '../builders'; import { ActionRow, Embed, PollBuilder, resolveAttachment } from '../builders';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import type { import type {
EmojiResolvable, EmojiResolvable,
@ -254,10 +254,10 @@ export class MessagesMethods extends DiscordBase {
const poll = (body as MessageCreateBodyRequest).poll; const poll = (body as MessageCreateBodyRequest).poll;
return { return {
...body, ...body,
components: body.components?.map(x => ('toJSON' in x ? x.toJSON() : x)) ?? undefined, components: body.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)) ?? undefined,
embeds: body.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)) ?? undefined, embeds: body.embeds?.map(x => (x instanceof Embed ? x.toJSON() : x)) ?? undefined,
attachments: body.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) })) ?? undefined, attachments: body.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) })) ?? undefined,
poll: poll ? ('toJSON' in poll ? poll.toJSON() : poll) : undefined, poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined,
} as T; } as T;
} }
} }