Improve voice connection checking, take advantage of optional chaining operators

This commit is contained in:
Essem 2022-07-23 16:02:04 -05:00
parent df43f9eb9d
commit 398ce07bd2
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
11 changed files with 36 additions and 27 deletions

View file

@ -5,7 +5,7 @@ import { random } from "../utils/misc.js";
export default async (client, cluster, worker, ipc, member, oldChannel) => {
if (!oldChannel) return;
const connection = players.get(oldChannel.guild.id);
if (connection && oldChannel.id === connection.voiceChannel.id) {
if (oldChannel.id === connection?.voiceChannel.id) {
if (oldChannel.voiceMembers.filter((i) => i.id !== client.user.id && !i.bot).length === 0) {
connection.player.setPaused(true);
const waitMessage = await client.createMessage(connection.originalChannel.id, "🔊 Waiting 10 seconds for someone to return...");