diff options
| author | Max Isom <[email protected]> | 2020-03-19 17:39:55 -0500 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2020-03-19 17:39:55 -0500 |
| commit | 4659717e5f314d061f9748331c79d507df971f7f (patch) | |
| tree | 8f4f9b0443be9e49cd31feabe13b8f6c6f123a7f /src/utils | |
| parent | 362ce8998780db67e5775125c6d6e3fc4d63586f (diff) | |
| download | muse-4659717e5f314d061f9748331c79d507df971f7f.tar.xz muse-4659717e5f314d061f9748331c79d507df971f7f.zip | |
Require user to be in voice channel
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/channels.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/utils/channels.ts b/src/utils/channels.ts index bd56dd4..b27f5a6 100644 --- a/src/utils/channels.ts +++ b/src/utils/channels.ts @@ -1,4 +1,16 @@ -import {Guild, VoiceChannel} from 'discord.js'; +import {Guild, VoiceChannel, User} from 'discord.js'; + +export const isUserInVoice = (guild: Guild, user: User): boolean => { + let inVoice = false; + + guild.channels.cache.filter(channel => channel.type === 'voice').forEach(channel => { + if (channel.members.array().find(member => member.id === user.id)) { + inVoice = true; + } + }); + + return inVoice; +}; export const getSizeWithoutBots = (channel: VoiceChannel): number => channel.members.array().reduce((s, member) => { if (!member.user.bot) { |
