mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(VoiceChannel): Support video_quality_mode (v13) (#7785)
This commit is contained in:
@@ -9,7 +9,7 @@ const GuildChannel = require('../structures/GuildChannel');
|
||||
const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
||||
const ThreadChannel = require('../structures/ThreadChannel');
|
||||
const Webhook = require('../structures/Webhook');
|
||||
const { ThreadChannelTypes, ChannelTypes } = require('../util/Constants');
|
||||
const { ThreadChannelTypes, ChannelTypes, VideoQualityModes } = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
@@ -222,6 +222,7 @@ class GuildChannelManager extends CachedManager {
|
||||
* @property {ThreadAutoArchiveDuration} [defaultAutoArchiveDuration]
|
||||
* The default auto archive duration for all new threads in this channel
|
||||
* @property {?string} [rtcRegion] The RTC region of the channel
|
||||
* @property {?VideoQualityMode|number} [videoQualityMode] The camera video quality mode of the channel
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -270,6 +271,8 @@ class GuildChannelManager extends CachedManager {
|
||||
bitrate: data.bitrate ?? channel.bitrate,
|
||||
user_limit: data.userLimit ?? channel.userLimit,
|
||||
rtc_region: data.rtcRegion ?? channel.rtcRegion,
|
||||
video_quality_mode:
|
||||
typeof data.videoQualityMode === 'string' ? VideoQualityModes[data.videoQualityMode] : data.videoQualityMode,
|
||||
parent_id: parent,
|
||||
lock_permissions: data.lockPermissions,
|
||||
rate_limit_per_user: data.rateLimitPerUser,
|
||||
|
||||
@@ -18,6 +18,7 @@ const {
|
||||
VerificationLevels,
|
||||
DefaultMessageNotificationLevels,
|
||||
ExplicitContentFilterLevels,
|
||||
VideoQualityModes,
|
||||
} = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const Permissions = require('../util/Permissions');
|
||||
@@ -94,6 +95,7 @@ class GuildManager extends CachedManager {
|
||||
* @property {number} [bitrate] The bitrate of the voice channel
|
||||
* @property {number} [userLimit] The user limit of the channel
|
||||
* @property {?string} [rtcRegion] The RTC region of the channel
|
||||
* @property {VideoQualityMode|number} [videoQualityMode] The camera video quality mode of the channel
|
||||
* @property {PartialOverwriteData[]} [permissionOverwrites]
|
||||
* Overwrites of the channel
|
||||
* @property {number} [rateLimitPerUser] The rate limit per user (slowmode) of the channel in seconds
|
||||
@@ -200,6 +202,11 @@ class GuildManager extends CachedManager {
|
||||
delete channel.rateLimitPerUser;
|
||||
channel.rtc_region = channel.rtcRegion;
|
||||
delete channel.rtcRegion;
|
||||
channel.video_quality_mode =
|
||||
typeof channel.videoQualityMode === 'string'
|
||||
? VideoQualityModes[channel.videoQualityMode]
|
||||
: channel.videoQualityMode;
|
||||
delete channel.videoQualityMode;
|
||||
|
||||
if (!channel.permissionOverwrites) continue;
|
||||
for (const overwrite of channel.permissionOverwrites) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const process = require('node:process');
|
||||
const BaseGuildVoiceChannel = require('./BaseGuildVoiceChannel');
|
||||
const { VideoQualityModes } = require('../util/Constants');
|
||||
const Permissions = require('../util/Permissions');
|
||||
|
||||
let deprecationEmittedForEditable = false;
|
||||
@@ -11,6 +12,20 @@ let deprecationEmittedForEditable = false;
|
||||
* @extends {BaseGuildVoiceChannel}
|
||||
*/
|
||||
class VoiceChannel extends BaseGuildVoiceChannel {
|
||||
_patch(data) {
|
||||
super._patch(data);
|
||||
|
||||
if ('video_quality_mode' in data) {
|
||||
/**
|
||||
* The camera video quality mode of the channel.
|
||||
* @type {?VideoQualityMode}
|
||||
*/
|
||||
this.videoQualityMode = VideoQualityModes[data.videoQualityMode];
|
||||
} else {
|
||||
this.videoQualityMode ??= null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the channel is editable by the client user
|
||||
* @type {boolean}
|
||||
@@ -87,6 +102,16 @@ class VoiceChannel extends BaseGuildVoiceChannel {
|
||||
return this.edit({ userLimit }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera video quality mode of the channel.
|
||||
* @param {VideoQualityMode|number} videoQualityMode The new camera video quality mode.
|
||||
* @param {string} [reason] Reason for changing the camera video quality mode.
|
||||
* @returns {Promise<VoiceChannel>}
|
||||
*/
|
||||
setVideoQualityMode(videoQualityMode, reason) {
|
||||
return this.edit({ videoQualityMode }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the RTC region of the channel.
|
||||
* @name VoiceChannel#setRTCRegion
|
||||
|
||||
@@ -1203,6 +1203,15 @@ exports.GuildScheduledEventStatuses = createEnum([null, 'SCHEDULED', 'ACTIVE', '
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types}
|
||||
*/
|
||||
exports.GuildScheduledEventEntityTypes = createEnum([null, 'STAGE_INSTANCE', 'VOICE', 'EXTERNAL']);
|
||||
|
||||
/**
|
||||
* The camera video quality mode of a {@link VoiceChannel}:
|
||||
* * AUTO
|
||||
* * FULL
|
||||
* @typedef {string} VideoQualityMode
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes}
|
||||
*/
|
||||
exports.VideoQualityModes = createEnum([null, 'AUTO', 'FULL']);
|
||||
/* eslint-enable max-len */
|
||||
|
||||
exports._cleanupSymbol = Symbol('djsCleanup');
|
||||
@@ -1256,6 +1265,7 @@ function createEnum(keys) {
|
||||
* @property {StickerFormatType} StickerFormatTypes The value set for a sticker's format type.
|
||||
* @property {StickerType} StickerTypes The value set for a sticker's type.
|
||||
* @property {VerificationLevel} VerificationLevels The value set for the verification levels for a guild.
|
||||
* @property {VideoQualityMode} VideoQualityModes The camera video quality mode for a {@link VoiceChannel}.
|
||||
* @property {WebhookType} WebhookTypes The value set for a webhook's type.
|
||||
* @property {WSEventType} WSEvents The type of a WebSocket message event.
|
||||
*/
|
||||
|
||||
5
typings/enums.d.ts
vendored
5
typings/enums.d.ts
vendored
@@ -205,6 +205,11 @@ export const enum VerificationLevels {
|
||||
VERY_HIGH = 4,
|
||||
}
|
||||
|
||||
export const enum VideoQualityModes {
|
||||
AUTO = 1,
|
||||
FULL = 2,
|
||||
}
|
||||
|
||||
export const enum WebhookTypes {
|
||||
Incoming = 1,
|
||||
'Channel Follower' = 2,
|
||||
|
||||
8
typings/index.d.ts
vendored
8
typings/index.d.ts
vendored
@@ -89,6 +89,7 @@ import {
|
||||
GuildScheduledEventEntityTypes,
|
||||
GuildScheduledEventStatuses,
|
||||
GuildScheduledEventPrivacyLevels,
|
||||
VideoQualityModes,
|
||||
} from './enums';
|
||||
import {
|
||||
RawActivityData,
|
||||
@@ -2635,12 +2636,14 @@ export class Formatters extends null {
|
||||
}
|
||||
|
||||
export class VoiceChannel extends BaseGuildVoiceChannel {
|
||||
public videoQualityMode: VideoQualityMode | null;
|
||||
/** @deprecated Use manageable instead */
|
||||
public readonly editable: boolean;
|
||||
public readonly speakable: boolean;
|
||||
public type: 'GUILD_VOICE';
|
||||
public setBitrate(bitrate: number, reason?: string): Promise<VoiceChannel>;
|
||||
public setUserLimit(userLimit: number, reason?: string): Promise<VoiceChannel>;
|
||||
public setVideoQualityMode(videoQualityMode: VideoQualityMode | number, reason?: string): Promise<VoiceChannel>;
|
||||
}
|
||||
|
||||
export class VoiceRegion {
|
||||
@@ -2992,6 +2995,7 @@ export const Constants: {
|
||||
GuildScheduledEventEntityTypes: EnumHolder<typeof GuildScheduledEventEntityTypes>;
|
||||
GuildScheduledEventStatuses: EnumHolder<typeof GuildScheduledEventStatuses>;
|
||||
GuildScheduledEventPrivacyLevels: EnumHolder<typeof GuildScheduledEventPrivacyLevels>;
|
||||
VideoQualityModes: EnumHolder<typeof VideoQualityModes>;
|
||||
};
|
||||
|
||||
export const version: string;
|
||||
@@ -4048,6 +4052,7 @@ export interface ChannelData {
|
||||
permissionOverwrites?: readonly OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
|
||||
defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
|
||||
rtcRegion?: string | null;
|
||||
videoQualityMode?: VideoQualityMode | null;
|
||||
}
|
||||
|
||||
export interface ChannelLogsQueryOptions {
|
||||
@@ -5553,6 +5558,7 @@ export interface PartialChannelData {
|
||||
bitrate?: number;
|
||||
userLimit?: number;
|
||||
rtcRegion?: string | null;
|
||||
videoQualityMode?: VideoQualityMode;
|
||||
permissionOverwrites?: PartialOverwriteData[];
|
||||
rateLimitPerUser?: number;
|
||||
}
|
||||
@@ -5890,6 +5896,8 @@ export interface Vanity {
|
||||
|
||||
export type VerificationLevel = keyof typeof VerificationLevels;
|
||||
|
||||
export type VideoQualityMode = keyof typeof VideoQualityModes;
|
||||
|
||||
export type VoiceBasedChannelTypes = VoiceBasedChannel['type'];
|
||||
|
||||
export type VoiceChannelResolvable = Snowflake | VoiceChannel;
|
||||
|
||||
Reference in New Issue
Block a user