mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
change: prettier code
This commit is contained in:
committed by
GitHub Action
parent
a8ccf05e8b
commit
baf8583976
@@ -1,4 +1,4 @@
|
|||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
import type { ApplicationCommandPermissions } from "../../../types/interactions/commands/application_command_permissions.ts";
|
import type { ApplicationCommandPermissions } from "../../../types/interactions/commands/application_command_permissions.ts";
|
||||||
|
|
||||||
/** Batch edits permissions for all commands in a guild. Takes an array of partial GuildApplicationCommandPermissions objects including `id` and `permissions`. */
|
/** Batch edits permissions for all commands in a guild. Takes an array of partial GuildApplicationCommandPermissions objects including `id` and `permissions`. */
|
||||||
@@ -7,5 +7,10 @@ export async function batchEditSlashCommandPermissions(
|
|||||||
guildId: bigint,
|
guildId: bigint,
|
||||||
options: { id: string; permissions: ApplicationCommandPermissions[] }[]
|
options: { id: string; permissions: ApplicationCommandPermissions[] }[]
|
||||||
) {
|
) {
|
||||||
return await bot.rest.runMethod(bot.rest,"put", bot.constants.endpoints.COMMANDS_PERMISSIONS(bot.applicationId, guildId), options);
|
return await bot.rest.runMethod(
|
||||||
|
bot.rest,
|
||||||
|
"put",
|
||||||
|
bot.constants.endpoints.COMMANDS_PERMISSIONS(bot.applicationId, guildId),
|
||||||
|
options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||||
import type { CreateGlobalApplicationCommand } from "../../../types/interactions/commands/create_global_application_command.ts";
|
import type { CreateGlobalApplicationCommand } from "../../../types/interactions/commands/create_global_application_command.ts";
|
||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There are two kinds of Slash Commands: global commands and guild commands. Global commands are available for every guild that adds your app; guild commands are specific to the guild you specify when making them. Command names are unique per application within each scope (global and guild). That means:
|
* There are two kinds of Slash Commands: global commands and guild commands. Global commands are available for every guild that adds your app; guild commands are specific to the guild you specify when making them. Command names are unique per application within each scope (global and guild). That means:
|
||||||
@@ -19,7 +19,9 @@ export async function createSlashCommand(bot: Bot, options: CreateGlobalApplicat
|
|||||||
return await bot.rest.runMethod<ApplicationCommand>(
|
return await bot.rest.runMethod<ApplicationCommand>(
|
||||||
bot.rest,
|
bot.rest,
|
||||||
"post",
|
"post",
|
||||||
guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId),
|
guildId
|
||||||
|
? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId)
|
||||||
|
: bot.constants.endpoints.COMMANDS(bot.applicationId),
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import type { Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/** Deletes a slash command. */
|
/** Deletes a slash command. */
|
||||||
export async function deleteSlashCommand(bot: Bot, id: bigint, guildId?: bigint) {
|
export async function deleteSlashCommand(bot: Bot, id: bigint, guildId?: bigint) {
|
||||||
return await bot.rest.runMethod<undefined>(
|
return await bot.rest.runMethod<undefined>(
|
||||||
bot.rest,
|
bot.rest,
|
||||||
"delete",
|
"delete",
|
||||||
guildId ? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, id) : bot.constants.endpoints.COMMANDS_ID(bot.applicationId, id)
|
guildId
|
||||||
|
? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, id)
|
||||||
|
: bot.constants.endpoints.COMMANDS_ID(bot.applicationId, id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/** To delete your response to a slash command. If a message id is not provided, it will default to deleting the original response. */
|
/** To delete your response to a slash command. If a message id is not provided, it will default to deleting the original response. */
|
||||||
export async function deleteSlashResponse(bot: Bot, token: string, messageId?: bigint) {
|
export async function deleteSlashResponse(bot: Bot, token: string, messageId?: bigint) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { ApplicationCommandPermissions } from "../../../types/interactions/commands/application_command_permissions.ts";
|
import type { ApplicationCommandPermissions } from "../../../types/interactions/commands/application_command_permissions.ts";
|
||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/** Edits command permissions for a specific command for your application in a guild. */
|
/** Edits command permissions for a specific command for your application in a guild. */
|
||||||
export async function editSlashCommandPermissions(
|
export async function editSlashCommandPermissions(
|
||||||
@@ -8,7 +8,12 @@ export async function editSlashCommandPermissions(
|
|||||||
commandId: bigint,
|
commandId: bigint,
|
||||||
options: ApplicationCommandPermissions[]
|
options: ApplicationCommandPermissions[]
|
||||||
) {
|
) {
|
||||||
return await bot.rest.runMethod(bot.rest,"put", bot.constants.endpoints.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId), {
|
return await bot.rest.runMethod(
|
||||||
|
bot.rest,
|
||||||
|
"put",
|
||||||
|
bot.constants.endpoints.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId),
|
||||||
|
{
|
||||||
permissions: options,
|
permissions: options,
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { DiscordenoEditWebhookMessage } from "../../../types/discordeno/edit_webhook_message.ts";
|
import type { DiscordenoEditWebhookMessage } from "../../../types/discordeno/edit_webhook_message.ts";
|
||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
import {DiscordAllowedMentionsTypes} from "../../../types/messages/allowed_mentions_types.ts";
|
import { DiscordAllowedMentionsTypes } from "../../../types/messages/allowed_mentions_types.ts";
|
||||||
|
|
||||||
/** To edit your response to a slash command. If a messageId is not provided it will default to editing the original response. */
|
/** To edit your response to a slash command. If a messageId is not provided it will default to editing the original response. */
|
||||||
export async function editSlashResponse(bot: Bot, token: string, options: DiscordenoEditWebhookMessage) {
|
export async function editSlashResponse(bot: Bot, token: string, options: DiscordenoEditWebhookMessage) {
|
||||||
@@ -48,12 +48,14 @@ export async function editSlashResponse(bot: Bot, token: string, options: Discor
|
|||||||
content: options.content,
|
content: options.content,
|
||||||
embeds: options.embeds,
|
embeds: options.embeds,
|
||||||
file: options.file,
|
file: options.file,
|
||||||
allowed_mentions: options.allowedMentions ? {
|
allowed_mentions: options.allowedMentions
|
||||||
|
? {
|
||||||
parse: options.allowedMentions.parse,
|
parse: options.allowedMentions.parse,
|
||||||
roles: options.allowedMentions.roles,
|
roles: options.allowedMentions.roles,
|
||||||
users: options.allowedMentions.users,
|
users: options.allowedMentions.users,
|
||||||
replied_user: options.allowedMentions.repliedUser
|
replied_user: options.allowedMentions.repliedUser,
|
||||||
} : undefined,
|
}
|
||||||
|
: undefined,
|
||||||
attachments: options.attachments,
|
attachments: options.attachments,
|
||||||
// TODO: Snakelize components??
|
// TODO: Snakelize components??
|
||||||
components: options.components,
|
components: options.components,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/** Fetches the global command for the given Id. If a guildId is provided, the guild command will be fetched. */
|
/** Fetches the global command for the given Id. If a guildId is provided, the guild command will be fetched. */
|
||||||
export async function getSlashCommand(bot: Bot, commandId: bigint, guildId?: bigint) {
|
export async function getSlashCommand(bot: Bot, commandId: bigint, guildId?: bigint) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { GuildApplicationCommandPermissions } from "../../../types/interactions/commands/guild_application_command_permissions.ts";
|
import type { GuildApplicationCommandPermissions } from "../../../types/interactions/commands/guild_application_command_permissions.ts";
|
||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/** Fetches command permissions for a specific command for your application in a guild. Returns a GuildApplicationCommandPermissions object. */
|
/** Fetches command permissions for a specific command for your application in a guild. Returns a GuildApplicationCommandPermissions object. */
|
||||||
export async function getSlashCommandPermission(bot: Bot, guildId: bigint, commandId: bigint) {
|
export async function getSlashCommandPermission(bot: Bot, guildId: bigint, commandId: bigint) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
import type { GuildApplicationCommandPermissions } from "../../../types/interactions/commands/guild_application_command_permissions.ts";
|
import type { GuildApplicationCommandPermissions } from "../../../types/interactions/commands/guild_application_command_permissions.ts";
|
||||||
|
|
||||||
/** Fetches command permissions for all commands for your application in a guild. Returns an array of GuildApplicationCommandPermissions objects. */
|
/** Fetches command permissions for all commands for your application in a guild. Returns an array of GuildApplicationCommandPermissions objects. */
|
||||||
|
|||||||
@@ -1,19 +1,25 @@
|
|||||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||||
import { Collection } from "../../../util/collection.ts";
|
import { Collection } from "../../../util/collection.ts";
|
||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/** Fetch all the global commands for your application. */
|
/** Fetch all the global commands for your application. */
|
||||||
export async function getSlashCommands(bot: Bot, guildId?: bigint) {
|
export async function getSlashCommands(bot: Bot, guildId?: bigint) {
|
||||||
const result = await bot.rest.runMethod<ApplicationCommand[]>(
|
const result = await bot.rest.runMethod<ApplicationCommand[]>(
|
||||||
bot.rest,
|
bot.rest,
|
||||||
"get",
|
"get",
|
||||||
guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId)
|
guildId
|
||||||
|
? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId)
|
||||||
|
: bot.constants.endpoints.COMMANDS(bot.applicationId)
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Collection(
|
return new Collection(
|
||||||
result.map((command) => [
|
result.map((command) => [
|
||||||
command.name,
|
command.name,
|
||||||
{ ...command, id: bot.transformers.snowflake(command.id), applicationId: bot.transformers.snowflake(command.applicationId) },
|
{
|
||||||
|
...command,
|
||||||
|
id: bot.transformers.snowflake(command.id),
|
||||||
|
applicationId: bot.transformers.snowflake(command.applicationId),
|
||||||
|
},
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||||
import type { EditGlobalApplicationCommand } from "../../../types/interactions/commands/edit_global_application_command.ts";
|
import type { EditGlobalApplicationCommand } from "../../../types/interactions/commands/edit_global_application_command.ts";
|
||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit an existing slash command. If this command did not exist, it will create it.
|
* Edit an existing slash command. If this command did not exist, it will create it.
|
||||||
*/
|
*/
|
||||||
export async function upsertSlashCommand(bot: Bot, commandId: bigint, options: EditGlobalApplicationCommand, guildId?: bigint) {
|
export async function upsertSlashCommand(
|
||||||
|
bot: Bot,
|
||||||
|
commandId: bigint,
|
||||||
|
options: EditGlobalApplicationCommand,
|
||||||
|
guildId?: bigint
|
||||||
|
) {
|
||||||
[options] = bot.utils.validateSlashCommands([options]);
|
[options] = bot.utils.validateSlashCommands([options]);
|
||||||
|
|
||||||
return await bot.rest.runMethod<ApplicationCommand>(
|
return await bot.rest.runMethod<ApplicationCommand>(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||||
import type { EditGlobalApplicationCommand } from "../../../types/interactions/commands/edit_global_application_command.ts";
|
import type { EditGlobalApplicationCommand } from "../../../types/interactions/commands/edit_global_application_command.ts";
|
||||||
import type { MakeRequired } from "../../../types/util.ts";
|
import type { MakeRequired } from "../../../types/util.ts";
|
||||||
import type {Bot} from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bulk edit existing slash commands. If a command does not exist, it will create it.
|
* Bulk edit existing slash commands. If a command does not exist, it will create it.
|
||||||
@@ -18,7 +18,9 @@ export async function upsertSlashCommands(
|
|||||||
return await bot.rest.runMethod<ApplicationCommand[]>(
|
return await bot.rest.runMethod<ApplicationCommand[]>(
|
||||||
bot.rest,
|
bot.rest,
|
||||||
"put",
|
"put",
|
||||||
guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId),
|
guildId
|
||||||
|
? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId)
|
||||||
|
: bot.constants.endpoints.COMMANDS(bot.applicationId),
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import type {Bot} from "../../bot.ts";
|
import type { Bot } from "../../bot.ts";
|
||||||
import type { Message } from "../../types/messages/message.ts";
|
import type { Message } from "../../types/messages/message.ts";
|
||||||
import type {SnakeCasedPropertiesDeep} from "../../types/util.ts";
|
import type { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||||
|
|
||||||
/** Returns the initial Interaction response. Functions the same as Get Webhook Message */
|
/** Returns the initial Interaction response. Functions the same as Get Webhook Message */
|
||||||
export async function getOriginalInteractionResponse(bot: Bot, token: string) {
|
export async function getOriginalInteractionResponse(bot: Bot, token: string) {
|
||||||
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Message>>(bot.rest,"get", bot.constants.endpoints.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token));
|
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Message>>(
|
||||||
|
bot.rest,
|
||||||
|
"get",
|
||||||
|
bot.constants.endpoints.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token)
|
||||||
|
);
|
||||||
|
|
||||||
return bot.transformers.message(result);
|
return bot.transformers.message(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import type { DiscordenoInteractionResponse } from "../../types/discordeno/interaction_response.ts";
|
import type { DiscordenoInteractionResponse } from "../../types/discordeno/interaction_response.ts";
|
||||||
import type {Bot} from "../../bot.ts";
|
import type { Bot } from "../../bot.ts";
|
||||||
import {Embed} from "../../types/embeds/embed.ts";
|
import { Embed } from "../../types/embeds/embed.ts";
|
||||||
import {AllowedMentions} from "../../types/messages/allowed_mentions.ts";
|
import { AllowedMentions } from "../../types/messages/allowed_mentions.ts";
|
||||||
import {MessageReference} from "../../types/messages/message_reference.ts";
|
import { MessageReference } from "../../types/messages/message_reference.ts";
|
||||||
import {FileContent} from "../../types/discordeno/file_content.ts";
|
import { FileContent } from "../../types/discordeno/file_content.ts";
|
||||||
import {MessageComponents} from "../../types/messages/components/message_components.ts";
|
import { MessageComponents } from "../../types/messages/components/message_components.ts";
|
||||||
|
|
||||||
// TODO: v12 remove | string
|
// TODO: v12 remove | string
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +34,7 @@ export async function sendInteractionResponse(
|
|||||||
|
|
||||||
// If its already been executed, we need to send a followup response
|
// If its already been executed, we need to send a followup response
|
||||||
if (bot.cache.executedSlashCommands.has(token)) {
|
if (bot.cache.executedSlashCommands.has(token)) {
|
||||||
return await bot.rest.runMethod(bot.rest,"post", bot.cosntants.endpoints.WEBHOOK(bot.applicationId, token), {
|
return await bot.rest.runMethod(bot.rest, "post", bot.cosntants.endpoints.WEBHOOK(bot.applicationId, token), {
|
||||||
content: options.data.content,
|
content: options.data.content,
|
||||||
tts: options.data.tts,
|
tts: options.data.tts,
|
||||||
embeds: options.data.embeds,
|
embeds: options.data.embeds,
|
||||||
@@ -42,7 +42,7 @@ export async function sendInteractionResponse(
|
|||||||
parse: options.data.allowedMentions.parse,
|
parse: options.data.allowedMentions.parse,
|
||||||
roles: options.data.allowedMentions.roles,
|
roles: options.data.allowedMentions.roles,
|
||||||
users: options.data.allowedMentions.users,
|
users: options.data.allowedMentions.users,
|
||||||
replied_user: options.data.allowedMentions.repliedUser
|
replied_user: options.data.allowedMentions.repliedUser,
|
||||||
},
|
},
|
||||||
...(options.data.messageReference?.messageId
|
...(options.data.messageReference?.messageId
|
||||||
? {
|
? {
|
||||||
@@ -57,7 +57,7 @@ export async function sendInteractionResponse(
|
|||||||
file: options.data.file,
|
file: options.data.file,
|
||||||
// TODO: Snakelize components??
|
// TODO: Snakelize components??
|
||||||
components: options.data.components,
|
components: options.data.components,
|
||||||
flags: options.data.flags
|
flags: options.data.flags,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ export async function sendInteractionResponse(
|
|||||||
parse: options.data.allowedMentions.parse,
|
parse: options.data.allowedMentions.parse,
|
||||||
roles: options.data.allowedMentions.roles,
|
roles: options.data.allowedMentions.roles,
|
||||||
users: options.data.allowedMentions.users,
|
users: options.data.allowedMentions.users,
|
||||||
replied_user: options.data.allowedMentions.repliedUser
|
replied_user: options.data.allowedMentions.repliedUser,
|
||||||
},
|
},
|
||||||
...(options.data.messageReference?.messageId
|
...(options.data.messageReference?.messageId
|
||||||
? {
|
? {
|
||||||
@@ -95,7 +95,7 @@ export async function sendInteractionResponse(
|
|||||||
file: options.data.file,
|
file: options.data.file,
|
||||||
// TODO: Snakelize components??
|
// TODO: Snakelize components??
|
||||||
components: options.data.components,
|
components: options.data.components,
|
||||||
flags: options.data.flags
|
flags: options.data.flags,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export async function sendMessage(bot: Bot, channelId: bigint, content: string |
|
|||||||
parse: content.allowedMentions.parse,
|
parse: content.allowedMentions.parse,
|
||||||
roles: content.allowedMentions.roles,
|
roles: content.allowedMentions.roles,
|
||||||
users: content.allowedMentions.users,
|
users: content.allowedMentions.users,
|
||||||
replied_user: content.allowedMentions.repliedUser
|
replied_user: content.allowedMentions.repliedUser,
|
||||||
},
|
},
|
||||||
file: content.file,
|
file: content.file,
|
||||||
// TODO: Snakelize components??
|
// TODO: Snakelize components??
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export async function editWebhookMessage(
|
|||||||
parse: content.allowedMentions.parse,
|
parse: content.allowedMentions.parse,
|
||||||
roles: content.allowedMentions.roles,
|
roles: content.allowedMentions.roles,
|
||||||
users: content.allowedMentions.users,
|
users: content.allowedMentions.users,
|
||||||
replied_user: content.allowedMentions.repliedUser
|
replied_user: content.allowedMentions.repliedUser,
|
||||||
},
|
},
|
||||||
attachments: options.attachments,
|
attachments: options.attachments,
|
||||||
// TODO: Snakelize components??
|
// TODO: Snakelize components??
|
||||||
|
|||||||
Reference in New Issue
Block a user