Join the message sender's channel if possible

This commit is contained in:
Luis Ávila 2021-09-15 23:12:48 +01:00
parent c97206bb8b
commit cd9d5248ac
No known key found for this signature in database
GPG key ID: 88BC24179A6B16E0
3 changed files with 23 additions and 11 deletions

View file

@ -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;