aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2021-09-16 09:36:33 -0400
committerGitHub <[email protected]>2021-09-16 09:36:33 -0400
commit81bbdb971d4221063b16fc2150ed9f4c56041765 (patch)
treea7a033c54a28084b6d07bb269bd561d0e43e637a /src/utils
parentc97206bb8b691c5b43932fa9a4f575d57914d731 (diff)
parentcd9d5248acae76a48930d77842cf7845fb1fbe0e (diff)
downloadmuse-81bbdb971d4221063b16fc2150ed9f4c56041765.tar.xz
muse-81bbdb971d4221063b16fc2150ed9f4c56041765.zip
Merge pull request #330 from luisfavila/join-user-voice-channel
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/channels.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/utils/channels.ts b/src/utils/channels.ts
index b27f5a6..f46e469 100644
--- a/src/utils/channels.ts
+++ b/src/utils/channels.ts
@@ -1,4 +1,4 @@
-import {Guild, VoiceChannel, User} from 'discord.js';
+import {Guild, VoiceChannel, User, GuildMember} from 'discord.js';
export const isUserInVoice = (guild: Guild, user: User): boolean => {
let inVoice = false;
@@ -20,6 +20,18 @@ export const getSizeWithoutBots = (channel: VoiceChannel): number => channel.mem
return s;
}, 0);
+export const getMemberVoiceChannel = (member?: GuildMember): [VoiceChannel, number] | null => {
+ const channel = member?.voice?.channel;
+ if (channel && channel.type === 'voice') {
+ return [
+ channel,
+ getSizeWithoutBots(channel)
+ ];
+ }
+
+ return null;
+};
+
export const getMostPopularVoiceChannel = (guild: Guild): [VoiceChannel, number] => {
interface PopularResult {
n: number;