mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
fix: Invalid HTTP method in upserting commands. (#2448)
* fix: Export of `ApplicationCommandOptionChoice`. * fix: Invalid HTTP method for upserting application commands. * fmt: Run Deno formatter. Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
co-authored by
Skillz4Killz
parent
4aba5ff72f
commit
ec6b7459bd
@@ -23,7 +23,7 @@ export async function upsertGlobalApplicationCommands(
|
||||
): Promise<Collection<bigint, ApplicationCommand>> {
|
||||
const results = await bot.rest.runMethod<DiscordApplicationCommand[]>(
|
||||
bot.rest,
|
||||
"PATCH",
|
||||
"PUT",
|
||||
bot.constants.routes.COMMANDS(bot.applicationId),
|
||||
commands.map((command) => bot.transformers.reverse.createApplicationCommand(bot, command)),
|
||||
);
|
||||
|
||||
@@ -25,7 +25,7 @@ export async function upsertGuildApplicationCommands(
|
||||
): Promise<Collection<bigint, ApplicationCommand>> {
|
||||
const results = await bot.rest.runMethod<DiscordApplicationCommand[]>(
|
||||
bot.rest,
|
||||
"PATCH",
|
||||
"PUT",
|
||||
bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId),
|
||||
commands.map((command) => bot.transformers.reverse.createApplicationCommand(bot, command)),
|
||||
);
|
||||
|
||||
@@ -89,10 +89,10 @@ export class Embeds extends Array<Embed> {
|
||||
|
||||
setColor(color: string) {
|
||||
this.getLastEmbed().color = color.toLowerCase() === `random`
|
||||
? // Random color
|
||||
Math.floor(Math.random() * (0xffffff + 1))
|
||||
: // Convert the hex to a acceptable color for discord
|
||||
parseInt(color.replace("#", ""), 16);
|
||||
// Random color
|
||||
? Math.floor(Math.random() * (0xffffff + 1))
|
||||
// Convert the hex to a acceptable color for discord
|
||||
: parseInt(color.replace("#", ""), 16);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
+4
-4
@@ -13,10 +13,10 @@ export async function dispatchRequirements<B extends Bot>(
|
||||
|
||||
const id = bot.utils.snowflakeToBigint(
|
||||
(data.t && ["GUILD_UPDATE"].includes(data.t)
|
||||
? // deno-lint-ignore no-explicit-any
|
||||
(data.d as any)?.id
|
||||
: // deno-lint-ignore no-explicit-any
|
||||
(data.d as any)?.guild_id) ?? "",
|
||||
// deno-lint-ignore no-explicit-any
|
||||
? (data.d as any)?.id
|
||||
// deno-lint-ignore no-explicit-any
|
||||
: (data.d as any)?.guild_id) ?? "",
|
||||
);
|
||||
|
||||
if (!id || bot.activeGuildIds.has(id)) return;
|
||||
|
||||
@@ -16,10 +16,10 @@ export function setRawEvent() {
|
||||
|
||||
const id = bot.transformers.snowflake(
|
||||
(data.t && ["GUILD_UPDATE", "GUILD_CREATE"].includes(data.t)
|
||||
? // deno-lint-ignore no-explicit-any
|
||||
(data.d as any)?.id
|
||||
: // deno-lint-ignore no-explicit-any
|
||||
(data.d as any)?.guild_id) ?? "",
|
||||
// deno-lint-ignore no-explicit-any
|
||||
? (data.d as any)?.id
|
||||
// deno-lint-ignore no-explicit-any
|
||||
: (data.d as any)?.guild_id) ?? "",
|
||||
);
|
||||
|
||||
// The GUILD_CREATE event came from a shard loaded event so ignore it
|
||||
|
||||
@@ -168,8 +168,8 @@ export type ConvertArgumentDefinitionsToArgs<T extends readonly ArgumentDefiniti
|
||||
? T[P]["choices"][number]["value"]
|
||||
: string;
|
||||
}
|
||||
: // INTEGER
|
||||
T[P] extends IntegerOptionalArgumentDefinition<infer N> ? {
|
||||
// INTEGER
|
||||
: T[P] extends IntegerOptionalArgumentDefinition<infer N> ? {
|
||||
[_ in getName<N>]?: T[P]["choices"] extends readonly { name: string; value: number }[] // @ts-ignore
|
||||
? T[P]["choices"][number]["value"]
|
||||
: number;
|
||||
@@ -179,11 +179,11 @@ export type ConvertArgumentDefinitionsToArgs<T extends readonly ArgumentDefiniti
|
||||
? T[P]["choices"][number]["value"]
|
||||
: number;
|
||||
}
|
||||
: // BOOLEAN
|
||||
T[P] extends BooleanOptionalArgumentDefinition<infer N> ? { [_ in getName<N>]?: boolean }
|
||||
// BOOLEAN
|
||||
: T[P] extends BooleanOptionalArgumentDefinition<infer N> ? { [_ in getName<N>]?: boolean }
|
||||
: T[P] extends BooleanArgumentDefinition<infer N> ? { [_ in getName<N>]: boolean }
|
||||
: // USER
|
||||
T[P] extends UserOptionalArgumentDefinition<infer N> ? {
|
||||
// USER
|
||||
: T[P] extends UserOptionalArgumentDefinition<infer N> ? {
|
||||
[_ in getName<N>]?: {
|
||||
user: User;
|
||||
member: Member;
|
||||
@@ -195,14 +195,14 @@ export type ConvertArgumentDefinitionsToArgs<T extends readonly ArgumentDefiniti
|
||||
member: Member;
|
||||
};
|
||||
}
|
||||
: // CHANNEL
|
||||
T[P] extends ChannelOptionalArgumentDefinition<infer N> ? { [_ in getName<N>]?: Channel }
|
||||
// CHANNEL
|
||||
: T[P] extends ChannelOptionalArgumentDefinition<infer N> ? { [_ in getName<N>]?: Channel }
|
||||
: T[P] extends ChannelArgumentDefinition<infer N> ? { [_ in getName<N>]: Channel }
|
||||
: // ROLE
|
||||
T[P] extends RoleOptionalArgumentDefinition<infer N> ? { [_ in getName<N>]?: Role }
|
||||
// ROLE
|
||||
: T[P] extends RoleOptionalArgumentDefinition<infer N> ? { [_ in getName<N>]?: Role }
|
||||
: T[P] extends RoleArgumentDefinition<infer N> ? { [_ in getName<N>]: Role }
|
||||
: // MENTIONABLE
|
||||
T[P] extends MentionableOptionalArgumentDefinition<infer N> ? {
|
||||
// MENTIONABLE
|
||||
: T[P] extends MentionableOptionalArgumentDefinition<infer N> ? {
|
||||
[_ in getName<N>]?:
|
||||
| Role
|
||||
| {
|
||||
@@ -218,14 +218,14 @@ export type ConvertArgumentDefinitionsToArgs<T extends readonly ArgumentDefiniti
|
||||
member: Member;
|
||||
};
|
||||
}
|
||||
: // SUBCOMMAND
|
||||
T[P] extends SubcommandArgumentDefinition<infer N> ? {
|
||||
// SUBCOMMAND
|
||||
: T[P] extends SubcommandArgumentDefinition<infer N> ? {
|
||||
[_ in getName<N>]?: T[P]["options"] extends readonly ArgumentDefinition[] // @ts-ignore somehow this check does not work
|
||||
? ConvertArgumentDefinitionsToArgs<T[P]["options"]>
|
||||
: {};
|
||||
}
|
||||
: // SUBCOMMANDGROUP
|
||||
T[P] extends SubcommandGroupArgumentDefinition<infer N> ? {
|
||||
// SUBCOMMANDGROUP
|
||||
: T[P] extends SubcommandGroupArgumentDefinition<infer N> ? {
|
||||
[_ in getName<N>]?: ConvertArgumentDefinitionsToArgs<T[P]["options"]>;
|
||||
}
|
||||
: never;
|
||||
|
||||
@@ -136,8 +136,8 @@ function createOptions(
|
||||
choices,
|
||||
// @ts-ignore fix this
|
||||
options: option.options
|
||||
? // @ts-ignore fix this
|
||||
createOptions(bot, guildId, option.options)
|
||||
// @ts-ignore fix this
|
||||
? createOptions(bot, guildId, option.options)
|
||||
: undefined,
|
||||
} as ApplicationCommandOption);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ export function transformInvite(bot: Bot, invite: DiscordInviteCreate) {
|
||||
targetUser: invite.target_user ? bot.transformers.user(bot, invite.target_user) : undefined,
|
||||
/** The embedded application to open for this voice channel embedded application invite */
|
||||
targetApplication: invite.target_application
|
||||
? // @ts-ignore should not break anything even though its partial. if it does blame wolf :)
|
||||
bot.transformers.application(bot, invite.target_application)
|
||||
// @ts-ignore should not break anything even though its partial. if it does blame wolf :)
|
||||
? bot.transformers.application(bot, invite.target_application)
|
||||
: undefined,
|
||||
/** Whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role) */
|
||||
temporary: invite.temporary,
|
||||
|
||||
Reference in New Issue
Block a user