mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
change: use bigint for ids
This commit is contained in:
@@ -1,14 +1,21 @@
|
|||||||
import { applicationId } from "../../../bot.ts";
|
import { applicationId } from "../../../bot.ts";
|
||||||
import { rest } from "../../../rest/rest.ts";
|
import { rest } from "../../../rest/rest.ts";
|
||||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||||
|
import { snowflakeToBigint } from "../../../util/bigint.ts";
|
||||||
import { endpoints } from "../../../util/constants.ts";
|
import { endpoints } from "../../../util/constants.ts";
|
||||||
|
|
||||||
/** Fetchs the global command for the given Id. If a guildId is provided, the guild command will be fetched. */
|
/** Fetchs the global command for the given Id. If a guildId is provided, the guild command will be fetched. */
|
||||||
export async function getSlashCommand(commandId: bigint, guildId?: bigint) {
|
export async function getSlashCommand(commandId: bigint, guildId?: bigint) {
|
||||||
return await rest.runMethod<ApplicationCommand>(
|
const result = await rest.runMethod<ApplicationCommand>(
|
||||||
"get",
|
"get",
|
||||||
guildId
|
guildId
|
||||||
? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, commandId)
|
? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, commandId)
|
||||||
: endpoints.COMMANDS_ID(applicationId, commandId)
|
: endpoints.COMMANDS_ID(applicationId, commandId)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...result,
|
||||||
|
id: snowflakeToBigint(result.id),
|
||||||
|
applicationId: snowflakeToBigint(result.applicationId),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { applicationId } from "../../../bot.ts";
|
import { applicationId } from "../../../bot.ts";
|
||||||
import { rest } from "../../../rest/rest.ts";
|
import { rest } from "../../../rest/rest.ts";
|
||||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||||
|
import { snowflakeToBigint } from "../../../util/bigint.ts";
|
||||||
import { Collection } from "../../../util/collection.ts";
|
import { Collection } from "../../../util/collection.ts";
|
||||||
import { endpoints } from "../../../util/constants.ts";
|
import { endpoints } from "../../../util/constants.ts";
|
||||||
|
|
||||||
@@ -11,5 +12,10 @@ export async function getSlashCommands(guildId?: bigint) {
|
|||||||
guildId ? endpoints.COMMANDS_GUILD(applicationId, guildId) : endpoints.COMMANDS(applicationId)
|
guildId ? endpoints.COMMANDS_GUILD(applicationId, guildId) : endpoints.COMMANDS(applicationId)
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Collection(result.map((command) => [command.name, command]));
|
return new Collection(
|
||||||
|
result.map((command) => [
|
||||||
|
command.name,
|
||||||
|
{ ...command, id: snowflakeToBigint(command.id), applicationId: snowflakeToBigint(command.applicationId) },
|
||||||
|
])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user