Skip to content

Commit

Permalink
fix: remove casts when using makeURLSearchParams() (#8877)
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx authored Nov 28, 2022
1 parent 1a10f48 commit 7430c8e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/api/applicationCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ApplicationCommandsAPI {
*/
public async getGlobalCommands(applicationId: Snowflake, options: RESTGetAPIApplicationCommandsQuery = {}) {
return this.rest.get(Routes.applicationCommands(applicationId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIApplicationCommandsResult>;
}

Expand Down Expand Up @@ -109,7 +109,7 @@ export class ApplicationCommandsAPI {
data: RESTGetAPIApplicationGuildCommandsQuery = {},
) {
return this.rest.get(Routes.applicationGuildCommands(applicationId, guildId), {
query: makeURLSearchParams(data as Record<string, unknown>),
query: makeURLSearchParams(data),
}) as Promise<RESTGetAPIApplicationCommandsResult>;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/api/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class ChannelsAPI {
options: RESTGetAPIChannelMessageReactionUsersQuery = {},
) {
return this.rest.get(Routes.channelMessageReaction(channelId, messageId, encodeURIComponent(emoji)), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIChannelMessageReactionUsersResult>;
}

Expand Down Expand Up @@ -171,7 +171,7 @@ export class ChannelsAPI {
*/
public async getMessages(channelId: Snowflake, options: RESTGetAPIChannelMessagesQuery = {}) {
return this.rest.get(Routes.channelMessages(channelId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIChannelMessagesResult>;
}

Expand Down Expand Up @@ -305,7 +305,7 @@ export class ChannelsAPI {
options: RESTGetAPIChannelThreadsArchivedQuery = {},
) {
return this.rest.get(Routes.channelThreads(channelId, archivedStatus), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIChannelUsersThreadsArchivedResult>;
}

Expand All @@ -320,7 +320,7 @@ export class ChannelsAPI {
options: RESTGetAPIChannelThreadsArchivedQuery = {},
) {
return this.rest.get(Routes.channelJoinedArchivedThreads(channelId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIChannelUsersThreadsArchivedResult>;
}
}
14 changes: 7 additions & 7 deletions packages/core/src/api/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class GuildsAPI {
*/
public async getMembers(guildId: Snowflake, options: RESTGetAPIGuildMembersQuery = {}) {
return this.rest.get(Routes.guildMembers(guildId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIGuildMemberResult>;
}

Expand Down Expand Up @@ -314,7 +314,7 @@ export class GuildsAPI {
*/
public async getPruneCount(guildId: Snowflake, options: RESTGetAPIGuildPruneCountQuery = {}) {
return this.rest.get(Routes.guildPrune(guildId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIGuildPruneCountResult>;
}

Expand Down Expand Up @@ -535,7 +535,7 @@ export class GuildsAPI {
*/
public async getScheduledEvents(guildId: Snowflake, options: RESTGetAPIGuildScheduledEventsQuery = {}) {
return this.rest.get(Routes.guildScheduledEvents(guildId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIGuildScheduledEventsResult>;
}

Expand Down Expand Up @@ -566,7 +566,7 @@ export class GuildsAPI {
options: RESTGetAPIGuildScheduledEventQuery = {},
) {
return this.rest.get(Routes.guildScheduledEvent(guildId, eventId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIGuildScheduledEventResult>;
}

Expand Down Expand Up @@ -614,7 +614,7 @@ export class GuildsAPI {
options: RESTGetAPIGuildScheduledEventUsersQuery = {},
) {
return this.rest.get(Routes.guildScheduledEventUsers(guildId, eventId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIGuildScheduledEventUsersResult>;
}

Expand Down Expand Up @@ -740,7 +740,7 @@ export class GuildsAPI {
*/
public async getAuditLogs(guildId: Snowflake, options: RESTGetAPIAuditLogQuery = {}) {
return this.rest.get(Routes.guildAuditLog(guildId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIAuditLogResult>;
}

Expand Down Expand Up @@ -832,7 +832,7 @@ export class GuildsAPI {
*/
public async searchForMembers(guildId: Snowflake, options: RESTGetAPIGuildMembersSearchQuery) {
return this.rest.get(Routes.guildMembersSearch(guildId), {
query: makeURLSearchParams(options as unknown as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIGuildMembersSearchResult>;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/api/invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class InvitesAPI {
*/
public async get(code: string, options: RESTGetAPIInviteQuery = {}) {
return this.rest.get(Routes.invite(code), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIInviteResult>;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class UsersAPI {
*/
public async getGuilds(options: RESTGetAPICurrentUserGuildsQuery = {}) {
return this.rest.get(Routes.userGuilds(), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPICurrentUserGuildsResult>;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/api/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class WebhooksAPI {
options: RESTPostAPIWebhookWithTokenSlackQuery = {},
) {
await this.rest.post(Routes.webhookPlatform(id, token, 'slack'), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
body,
auth: false,
});
Expand All @@ -155,7 +155,7 @@ export class WebhooksAPI {
options: RESTPostAPIWebhookWithTokenGitHubQuery = {},
) {
await this.rest.post(Routes.webhookPlatform(id, token, 'github'), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
body,
auth: false,
});
Expand All @@ -171,7 +171,7 @@ export class WebhooksAPI {
*/
public async getMessage(id: Snowflake, token: string, messageId: Snowflake, options: { thread_id?: string } = {}) {
return this.rest.get(Routes.webhookMessage(id, token, messageId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
auth: false,
}) as Promise<RESTGetAPIChannelMessageResult>;
}
Expand Down Expand Up @@ -207,7 +207,7 @@ export class WebhooksAPI {
*/
public async deleteMessage(id: Snowflake, token: string, messageId: Snowflake, options: { thread_id?: string } = {}) {
await this.rest.delete(Routes.webhookMessage(id, token, messageId), {
query: makeURLSearchParams(options as Record<string, unknown>),
query: makeURLSearchParams(options),
auth: false,
});
}
Expand Down

0 comments on commit 7430c8e

Please sign in to comment.