feat: api docs catchup part 1 (#3257)

* feat: add voice message support

Closes #3009

* fix: pre-commit hook EACCESS npx issue

* feat: add channel to interaction

Closes #2979

* feat: add role flags

Closes #3070

* feat: adds creator monetization, message flagged, and member timeout audit log event

Closes #3075

* feat: add attachment flags

Closes #3071

* feat: add avatar decorations

Closes #3081

* feat: update description for guild and channel permissions

Closes #3106

* feat: rename Nitro sticker packs to just sticker packs

Closes #3107

* feat: add integration type to audit log entry

Closes #3108

* feat: make position optional on modify guild channel position

Closes #3086

* feat: add guild media channel type and associated flag

Closes #3093

* feat: update remark for activities.write scope

Closes  #3213

* feat: add support for super reactions

Closes #3113

* fix: attempt to fix benchmarks

* fix: benchmark attempt #2

---------

Co-authored-by: Fleny <Fleny113@outlook.com>
This commit is contained in:
Matthew Hatcher
2023-12-04 21:54:39 +00:00
committed by GitHub
co-authored by Fleny
parent c56bb063cb
commit e47242a9e0
23 changed files with 175 additions and 33 deletions
+3 -3
View File
@@ -375,8 +375,8 @@ export function createBotHelpers(bot: Bot): BotHelpers {
getMessages: async (channelId, options) => {
return (await bot.rest.getMessages(channelId, options)).map((res) => bot.transformers.message(bot, snakelize(res)))
},
getNitroStickerPacks: async () => {
return (await bot.rest.getNitroStickerPacks()).map((res) => bot.transformers.stickerPack(bot, snakelize(res)))
getStickerPacks: async () => {
return (await bot.rest.getStickerPacks()).map((res) => bot.transformers.stickerPack(bot, snakelize(res)))
},
getOriginalInteractionResponse: async (token) => {
return bot.transformers.message(bot, snakelize(await bot.rest.getOriginalInteractionResponse(token)))
@@ -790,7 +790,7 @@ export interface BotHelpers {
getInvites: (guildId: BigString) => Promise<Invite[]>
getMessage: (channelId: BigString, messageId: BigString) => Promise<Message>
getMessages: (channelId: BigString, options?: GetMessagesOptions) => Promise<Message[]>
getNitroStickerPacks: () => Promise<StickerPack[]>
getStickerPacks: () => Promise<StickerPack[]>
getOriginalInteractionResponse: (token: string) => Promise<Message>
getPinnedMessages: (channelId: BigString) => Promise<Message[]>
getPrivateArchivedThreads: (channelId: BigString, options?: ListArchivedThreads) => Promise<CamelizedDiscordArchivedThreads>
+12
View File
@@ -169,6 +169,9 @@ export interface Transformers {
width: boolean
ephemeral: boolean
description: boolean
duration_secs: boolean
waveform: boolean
flags: boolean
}
channel: {
type: boolean
@@ -268,6 +271,7 @@ export interface Transformers {
applicationId: boolean
type: boolean
guildId: boolean
channel: boolean
channelId: boolean
member: boolean
user: boolean
@@ -364,6 +368,7 @@ export interface Transformers {
hoist: boolean
managed: boolean
subscriptionListingId: boolean
flags: boolean
}
scheduledEvent: {
id: boolean
@@ -426,6 +431,7 @@ export interface Transformers {
verified: boolean
email: boolean
banner: boolean
avatarDecoration: boolean
}
webhook: {
id: boolean
@@ -652,6 +658,9 @@ export function createTransformers(options: Partial<Transformers>, opts?: Create
width: opts?.defaultDesiredPropertiesValue ?? false,
ephemeral: opts?.defaultDesiredPropertiesValue ?? false,
description: opts?.defaultDesiredPropertiesValue ?? false,
duration_secs: opts?.defaultDesiredPropertiesValue ?? false,
waveform: opts?.defaultDesiredPropertiesValue ?? false,
flags: opts?.defaultDesiredPropertiesValue ?? false,
},
channel: {
type: opts?.defaultDesiredPropertiesValue ?? false,
@@ -751,6 +760,7 @@ export function createTransformers(options: Partial<Transformers>, opts?: Create
applicationId: opts?.defaultDesiredPropertiesValue ?? false,
type: opts?.defaultDesiredPropertiesValue ?? false,
guildId: opts?.defaultDesiredPropertiesValue ?? false,
channel: opts?.defaultDesiredPropertiesValue ?? false,
channelId: opts?.defaultDesiredPropertiesValue ?? false,
member: opts?.defaultDesiredPropertiesValue ?? false,
user: opts?.defaultDesiredPropertiesValue ?? false,
@@ -847,6 +857,7 @@ export function createTransformers(options: Partial<Transformers>, opts?: Create
hoist: opts?.defaultDesiredPropertiesValue ?? false,
managed: opts?.defaultDesiredPropertiesValue ?? false,
subscriptionListingId: opts?.defaultDesiredPropertiesValue ?? false,
flags: opts?.defaultDesiredPropertiesValue ?? false,
},
scheduledEvent: {
id: opts?.defaultDesiredPropertiesValue ?? false,
@@ -909,6 +920,7 @@ export function createTransformers(options: Partial<Transformers>, opts?: Create
verified: opts?.defaultDesiredPropertiesValue ?? false,
email: opts?.defaultDesiredPropertiesValue ?? false,
banner: opts?.defaultDesiredPropertiesValue ?? false,
avatarDecoration: opts?.defaultDesiredPropertiesValue ?? false,
},
webhook: {
id: opts?.defaultDesiredPropertiesValue ?? false,
+10 -1
View File
@@ -1,4 +1,4 @@
import type { DiscordAttachment } from '@discordeno/types'
import type { AttachmentFlags, DiscordAttachment } from '@discordeno/types'
import type { Bot } from '../index.js'
export function transformAttachment(bot: Bot, payload: DiscordAttachment): Attachment {
@@ -15,6 +15,9 @@ export function transformAttachment(bot: Bot, payload: DiscordAttachment): Attac
if (props.width && payload.width) attachment.width = payload.width
if (props.ephemeral && payload.ephemeral) attachment.ephemeral = payload.ephemeral
if (props.description && payload.description) attachment.description = payload.description
if (props.duration_secs && payload.duration_secs) attachment.duration_secs = payload.duration_secs
if (props.waveform && payload.waveform) attachment.waveform = payload.waveform
if (props.flags && payload.flags) attachment.flags = payload.flags
return bot.transformers.customizers.attachment(bot, payload, attachment)
}
@@ -44,4 +47,10 @@ export interface Attachment {
* Ephemeral attachments on messages are guaranteed to be available as long as the message itself exists.
*/
ephemeral?: boolean
/** The duration of the audio file for a voice message */
duration_secs?: number
/** A base64 encoded bytearray representing a sampled waveform for a voice message */
waveform?: string
/** Attachment flags combined as a bitfield */
flags?: AttachmentFlags
}
@@ -128,6 +128,7 @@ export function transformAuditLogEntry(bot: Bot, payload: DiscordAuditLogEntry):
roleName: payload.options.role_name,
autoModerationRuleName: payload.options.auto_moderation_rule_name,
autoModerationRuleTriggerType: payload.options.auto_moderation_rule_trigger_type,
integrationType: payload.options.integration_type,
}
: undefined,
reason: payload.reason,
@@ -252,5 +253,6 @@ export interface AuditLogEntry {
roleName: string
autoModerationRuleName: string
autoModerationRuleTriggerType: string
integrationType: string
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
import type { BigString, ChannelTypes, DiscordChannel, DiscordThreadMember, OverwriteReadable, VideoQualityModes } from '@discordeno/types'
import { calculatePermissions, type Bot } from '../index.js'
import { ChannelToggles } from './toggles/channel.js'
import { Permissions } from './toggles/Permissions.js'
import { ChannelToggles } from './toggles/channel.js'
const Mask = (1n << 64n) - 1n
@@ -188,7 +188,7 @@ export interface Channel extends BaseChannel {
member?: DiscordThreadMember
/** Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 */
default_auto_archive_duration?: number
/** computed permissions for the invoking user in the channel, including overwrites, only included when part of the resolved data received on a application command interaction */
/** computed permissions for the invoking user in the channel, including overwrites, only included when part of the resolved data received on a slash command interaction. This does not include implicit permissions, which may need to be checked separately. */
permissions?: Permissions
/** The flags of the channel */
flags?: number
+1 -1
View File
@@ -213,7 +213,7 @@ export interface Guild {
discoverySplash?: bigint
/** Id of the owner */
ownerId: bigint
/** Total permissions for the user in the guild (excludes overwrites) */
/** Total permissions for the user in the guild (excludes overwrites and implicit permissions) */
permissions: bigint
/** Id of afk channel */
afkChannelId?: bigint
+9 -1
View File
@@ -12,7 +12,7 @@ import {
type MessageComponentTypes,
} from '@discordeno/types'
import { Collection } from '@discordeno/utils'
import type { Bot, Component } from '../index.js'
import type { Bot, Channel, Component, DiscordChannel } from '../index.js'
import type { DiscordInteractionDataResolved } from '../typings.js'
import type { Attachment } from './attachment.js'
import type { Member } from './member.js'
@@ -34,6 +34,13 @@ export interface Interaction extends BaseInteraction {
/** The guild it was sent from */
guildId?: bigint
/** The channel it was sent from */
channel: Partial<Channel>
/**
* The ID of channel it was sent from
*
* @remarks
* It is recommended that you begin using this channel field to identify the source channel of the interaction as they may deprecate the existing channel_id field in the future.
*/
channelId?: bigint
/** Guild member data for the invoking user, including permissions */
member?: Member
@@ -162,6 +169,7 @@ export function transformInteraction(bot: Bot, payload: DiscordInteraction): Int
if (props.user) interaction.user = user
if (payload.app_permissions && props.appPermissions) interaction.appPermissions = bot.transformers.snowflake(payload.app_permissions)
if (payload.message && props.message) interaction.message = bot.transformers.message(bot, payload.message)
if (payload.channel && props.channel) interaction.channel = bot.transformers.channel(bot, { channel: payload.channel as DiscordChannel, guildId })
if (payload.channel_id && props.channelId) interaction.channelId = bot.transformers.snowflake(payload.channel_id)
if (payload.member && guildId && props.member) interaction.member = bot.transformers.member(bot, payload.member, guildId, user.id)
if (payload.data && props.data) {
+17
View File
@@ -225,10 +225,21 @@ export interface Message extends MessageBase {
reactions?: Array<{
/** Whether the current user reacted using this emoji */
me: boolean
/** Whether the current user super-reacted using this emoji */
meBurst: boolean
/** Times this emoji has been used to react */
count: number
/** Reaction count details object */
countDetails: {
/** Count of super reactions */
burst: number
/** Count of normal reactions */
normal: number
}
/** Emoji information */
emoji: Emoji
/** HEX colors used for super reaction */
burstColors: string[]
}>
/** Sent if the message contains stickers */
stickerItems?: Array<{
@@ -341,8 +352,14 @@ export function transformMessage(bot: Bot, payload: DiscordMessage): Message {
if (payload.reactions?.length && props.reactions) {
message.reactions = payload.reactions.map((reaction) => ({
me: reaction.me,
meBurst: reaction.me_burst,
count: reaction.count,
countDetails: {
burst: reaction.count_details.burst,
normal: reaction.count_details.normal,
},
emoji: bot.transformers.emoji(bot, reaction.emoji),
burstColors: reaction.burst_colors,
}))
}
if (props.stickerItems && payload.sticker_items?.length)
@@ -13,5 +13,8 @@ export function transformAttachmentToDiscordAttachment(bot: Bot, payload: Attach
width: payload.width,
ephemeral: payload.ephemeral,
description: payload.description,
duration_secs: payload.duration_secs,
waveform: payload.waveform,
flags: payload.flags,
}
}
@@ -146,6 +146,7 @@ export function transformAuditLogEntryToDiscordAuditLogEntry(bot: Bot, payload:
application_id: '',
auto_moderation_rule_name: payload.options.autoModerationRuleName,
auto_moderation_rule_trigger_type: payload.options.autoModerationRuleTriggerType,
integration_type: payload.options.integrationType,
}
: undefined,
reason: payload.reason,
+4 -1
View File
@@ -1,4 +1,4 @@
import type { BigString, DiscordRole } from '@discordeno/types'
import type { BigString, DiscordRole, RoleFlags } from '@discordeno/types'
import { iconHashToBigInt, type Bot } from '../index.js'
import { Permissions } from './toggles/Permissions.js'
import { RoleToggles } from './toggles/role.js'
@@ -51,6 +51,7 @@ export function transformRole(bot: Bot, payload: { role: DiscordRole } & { guild
if (payload.role.permissions && props.permissions) role.permissions = new Permissions(payload.role.permissions)
if (payload.role.icon && props.icon) role.icon = iconHashToBigInt(payload.role.icon)
if (payload.role.unicode_emoji && props.unicodeEmoji) role.unicodeEmoji = payload.role.unicode_emoji
if (payload.role.flags && props.flags) role.flags = payload.role.flags
if (payload.role.tags && (props.botId || props.integrationId || props.subscriptionListingId)) {
role.internalTags = {}
if (payload.role.tags.bot_id && props.botId) role.internalTags.botId = bot.transformers.snowflake(payload.role.tags.bot_id)
@@ -133,4 +134,6 @@ export interface Role extends BaseRole {
position: number
/** role unicode emoji */
unicodeEmoji?: string
/** Role flags combined as a bitfield */
flags: RoleFlags
}
+3
View File
@@ -39,6 +39,7 @@ export function transformUser(bot: Bot, payload: DiscordUser): User {
if (payload.premium_type && props.premiumType) user.premiumType = payload.premium_type
if (payload.avatar && props.avatar) user.avatar = iconHashToBigInt(payload.avatar)
if (payload.banner && props.banner) user.banner = iconHashToBigInt(payload.banner)
if (payload.avatar_decoration && props.avatarDecoration) user.avatarDecoration = iconHashToBigInt(payload.avatar_decoration)
if (payload.accent_color && props.accentColor) user.accentColor = payload.accent_color
return bot.transformers.customizers.user(bot, payload, user)
@@ -84,4 +85,6 @@ export interface User extends BaseUser {
email?: string
/** the user's banner, or null if unset */
banner?: bigint
/** the user's avatar decoration, or null if unset */
avatarDecoration?: bigint
}
+2
View File
@@ -227,4 +227,6 @@ export enum MessageFlags {
FailedToMentionSomeRolesInThread = 1 << 8,
/** Whether this message will not trigger push and desktop notifications */
SuppressNotifications = 1 << 12,
/** Whether this message is a voice message */
IsVoiceMessage = 1 << 13,
}