mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 16:57:22 +00:00
Merge pull request #1720 from Skillz4Killz/fp-attempt-9001
Fp attempt 9001
This commit is contained in:
@@ -110,6 +110,7 @@ import { AsyncCache, AsyncCacheHandler, Cache, CacheHandler, createCache, TableN
|
||||
import { transformThread } from "./transformers/thread.ts";
|
||||
import { transformWebhook } from "./transformers/webhook.ts";
|
||||
import { transformAuditlogEntry } from "./transformers/auditlogEntry.ts";
|
||||
import { transformApplicationCommandPermission } from "./transformers/applicationCommandPermission.ts";
|
||||
|
||||
type CacheOptions =
|
||||
| {
|
||||
@@ -848,6 +849,7 @@ export interface Transformers {
|
||||
thread: typeof transformThread;
|
||||
webhook: typeof transformWebhook;
|
||||
auditlogEntry: typeof transformAuditlogEntry;
|
||||
applicationCommandPermission: typeof transformApplicationCommandPermission
|
||||
}
|
||||
|
||||
export function createTransformers(options: Partial<Transformers>) {
|
||||
@@ -874,6 +876,7 @@ export function createTransformers(options: Partial<Transformers>) {
|
||||
snowflake: options.snowflake || snowflakeToBigint,
|
||||
webhook: options.webhook || transformWebhook,
|
||||
auditlogEntry: options.auditlogEntry || transformAuditlogEntry,
|
||||
applicationCommandPermission: transformApplicationCommandPermission
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import type { ApplicationCommandPermissions } from "../../../types/interactions/commands/application_command_permissions.ts";
|
||||
import { GuildApplicationCommandPermissions } from "../../../types/interactions/commands/guild_application_command_permissions.ts";
|
||||
|
||||
/** Batch edits permissions for all commands in a guild. Takes an array of partial GuildApplicationCommandPermissions objects including `id` and `permissions`. */
|
||||
export async function batchEditSlashCommandPermissions(
|
||||
@@ -7,10 +8,12 @@ export async function batchEditSlashCommandPermissions(
|
||||
guildId: bigint,
|
||||
options: { id: string; permissions: ApplicationCommandPermissions[] }[]
|
||||
) {
|
||||
return await bot.rest.runMethod(
|
||||
const result = await bot.rest.runMethod<GuildApplicationCommandPermissions[]>(
|
||||
bot.rest,
|
||||
"put",
|
||||
bot.constants.endpoints.COMMANDS_PERMISSIONS(bot.applicationId, guildId),
|
||||
options
|
||||
);
|
||||
|
||||
return result.map((res) => bot.transformers.applicationCommandPermission(bot, res));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ApplicationCommandPermissions } from "../../../types/interactions/commands/application_command_permissions.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import { GuildApplicationCommandPermissions } from "../../../types/interactions/commands/guild_application_command_permissions.ts";
|
||||
|
||||
/** Edits command permissions for a specific command for your application in a guild. */
|
||||
export async function editSlashCommandPermissions(
|
||||
@@ -8,7 +9,7 @@ export async function editSlashCommandPermissions(
|
||||
commandId: bigint,
|
||||
options: ApplicationCommandPermissions[]
|
||||
) {
|
||||
return await bot.rest.runMethod(
|
||||
const result = await bot.rest.runMethod<GuildApplicationCommandPermissions>(
|
||||
bot.rest,
|
||||
"put",
|
||||
bot.constants.endpoints.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId),
|
||||
@@ -16,4 +17,6 @@ export async function editSlashCommandPermissions(
|
||||
permissions: options,
|
||||
}
|
||||
);
|
||||
|
||||
return bot.transformers.applicationCommandPermission(bot, result);
|
||||
}
|
||||
|
||||
@@ -66,5 +66,5 @@ export interface DiscordenoApplication {
|
||||
/** If this application is a game sold on Discord, this field will be the hash of the image on store embeds */
|
||||
coverImage?: string;
|
||||
/** The application's public flags */
|
||||
flags: DiscordApplicationFlags;
|
||||
flags?: DiscordApplicationFlags;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { DiscordApplicationCommandPermissionTypes } from "../types/interactions/commands/application_command_permission_types.ts";
|
||||
import { GuildApplicationCommandPermissions } from "../types/interactions/commands/guild_application_command_permissions.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../types/util.ts";
|
||||
|
||||
export function transformApplicationCommandPermission(
|
||||
bot: Bot,
|
||||
payload: SnakeCasedPropertiesDeep<GuildApplicationCommandPermissions>
|
||||
): DiscordenoApplicationCommandPermission {
|
||||
return {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
applicationId: bot.transformers.snowflake(payload.application_id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
permissions: payload.permissions.map((perm) => ({
|
||||
id: bot.transformers.snowflake(perm.id),
|
||||
type: perm.type,
|
||||
permission: perm.permission,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
export interface DiscordenoApplicationCommandPermission {
|
||||
/** The id of the command */
|
||||
id: bigint;
|
||||
/** The id of the application to command belongs to */
|
||||
applicationId: bigint;
|
||||
/** The id of the guild */
|
||||
guildId: bigint;
|
||||
/** The permissions for the command in the guild */
|
||||
permissions: {
|
||||
/** The id of the role or user */
|
||||
id: bigint;
|
||||
/** Role or User */
|
||||
type: DiscordApplicationCommandPermissionTypes;
|
||||
/** `true` to allow, `false`, to disallow */
|
||||
permission: boolean;
|
||||
}[];
|
||||
}
|
||||
@@ -39,5 +39,5 @@ export interface Application {
|
||||
/** If this application is a game sold on Discord, this field will be the hash of the image on store embeds */
|
||||
coverImage?: string;
|
||||
/** The application's public flags */
|
||||
flags: DiscordApplicationFlags;
|
||||
flags?: DiscordApplicationFlags;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ export enum DiscordJsonErrorCodes {
|
||||
UnknownInteraction = 10062,
|
||||
UnknownApplicationCommand = 10063,
|
||||
UnknownApplicationCommandPermissions = 10066,
|
||||
UnknownGuildMemberVerificationForm = 10068,
|
||||
UnknownStageInstance,
|
||||
UnknownGuildMemberVerificationForm,
|
||||
BotsCannotUseThisEndpoint = 20001,
|
||||
OnlyBotsCanUseThisEndpoint,
|
||||
ExplicitContentCannotBeSentToTheDesiredRecipient = 20009,
|
||||
@@ -42,7 +43,7 @@ export enum DiscordJsonErrorCodes {
|
||||
OnlyTheOwnerOfThisAccountCanPerformThisAction = 20018,
|
||||
ThisMessageCannotBeEditedDueToAnnouncementRateLimits = 20022,
|
||||
TheChannelYouAreWritingHasHitTheWriteRateLimit = 20028,
|
||||
YourStageTopicContainsWordsThatAreNotAllowedForPublicStages = 20031,
|
||||
YourStageTopicOrServerNameOrServerDescriptionOrChannelNamesContainsWordsThatAreNotAllowedForPublicStages = 20031,
|
||||
GuildPremiumSubscriptionLevelTooLow = 20035,
|
||||
MaximumNumberOfGuildsReached = 30001,
|
||||
MaximumNumberOfFriendsReached,
|
||||
@@ -110,6 +111,7 @@ export enum DiscordJsonErrorCodes {
|
||||
NoUsersWithDiscordTagExist = 80004,
|
||||
ReqctionWasBlocked = 90001,
|
||||
ApiResourceIsCurrentlyOverloadedTryAgainALittleLater = 130000,
|
||||
TheStageIsAlreadyOpen = 150006,
|
||||
AThreadHasAlreadyBeenCreatedForThisMessage = 160004,
|
||||
ThreadIsLocked = 160005,
|
||||
MaximumNumberOfActiveThreadsReached = 160006,
|
||||
|
||||
@@ -11,14 +11,8 @@ export interface MessageSticker {
|
||||
name: string;
|
||||
/** Description of the sticker */
|
||||
description: string;
|
||||
/** For guild stickers, a unicode emoji representing the sticker's expression. For Nitro stickers, a comma-separated list of related expressions */
|
||||
/** a unicode emoji representing the sticker's expression */
|
||||
tags: string;
|
||||
/**
|
||||
* Sticker asset hash
|
||||
* Note: The URL for fetching sticker assets is currently private.
|
||||
* @deprecated the value of the asset field will an empty string.
|
||||
*/
|
||||
asset: string;
|
||||
/** Type of sticker format */
|
||||
formatType: DiscordMessageStickerFormatTypes;
|
||||
/** Whether or not the sticker is available */
|
||||
|
||||
Reference in New Issue
Block a user