mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
fix: correctly import VoiceState (#4616)
This commit is contained in:
@@ -1,14 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const VoiceState = require('../../structures/VoiceState');
|
|
||||||
const { Events } = require('../../util/Constants');
|
const { Events } = require('../../util/Constants');
|
||||||
|
const Structures = require('../../util/Structures');
|
||||||
|
|
||||||
class VoiceStateUpdate extends Action {
|
class VoiceStateUpdate extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
const client = this.client;
|
const client = this.client;
|
||||||
const guild = client.guilds.cache.get(data.guild_id);
|
const guild = client.guilds.cache.get(data.guild_id);
|
||||||
if (guild) {
|
if (guild) {
|
||||||
|
const VoiceState = Structures.get('VoiceState');
|
||||||
// Update the state
|
// Update the state
|
||||||
const oldState = guild.voiceStates.cache.has(data.user_id)
|
const oldState = guild.voiceStates.cache.has(data.user_id)
|
||||||
? guild.voiceStates.cache.get(data.user_id)._clone()
|
? guild.voiceStates.cache.get(data.user_id)._clone()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const BaseManager = require('./BaseManager');
|
const BaseManager = require('./BaseManager');
|
||||||
const VoiceState = require('../structures/VoiceState');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for VoiceStates and stores their cache.
|
* Manages API methods for VoiceStates and stores their cache.
|
||||||
@@ -9,7 +8,7 @@ const VoiceState = require('../structures/VoiceState');
|
|||||||
*/
|
*/
|
||||||
class VoiceStateManager extends BaseManager {
|
class VoiceStateManager extends BaseManager {
|
||||||
constructor(guild, iterable) {
|
constructor(guild, iterable) {
|
||||||
super(guild.client, iterable, VoiceState);
|
super(guild.client, iterable, { name: 'VoiceState' });
|
||||||
/**
|
/**
|
||||||
* The guild this manager belongs to
|
* The guild this manager belongs to
|
||||||
* @type {Guild}
|
* @type {Guild}
|
||||||
@@ -27,7 +26,7 @@ class VoiceStateManager extends BaseManager {
|
|||||||
const existing = this.cache.get(data.user_id);
|
const existing = this.cache.get(data.user_id);
|
||||||
if (existing) return existing._patch(data);
|
if (existing) return existing._patch(data);
|
||||||
|
|
||||||
const entry = new VoiceState(this.guild, data);
|
const entry = new this.holds(this.guild, data);
|
||||||
if (cache) this.cache.set(data.user_id, entry);
|
if (cache) this.cache.set(data.user_id, entry);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user