mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-11 12:21:37 +02:00
Join the message sender's channel if possible
This commit is contained in:
parent
c97206bb8b
commit
cd9d5248ac
3 changed files with 23 additions and 11 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue