aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
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 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) {