本文整理汇总了TypeScript中discord.js.Client.leaveVoiceChannel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.Client.leaveVoiceChannel方法的具体用法?TypeScript js.Client.leaveVoiceChannel怎么用?TypeScript js.Client.leaveVoiceChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类discord.js.Client
的用法示例。
在下文中一共展示了js.Client.leaveVoiceChannel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: reevaluateVoiceChannel
/**
* Finds the most populous voice channel and joins it
*/
function reevaluateVoiceChannel(server:Discord.Server):Promise<any> {
if (server.channels.length === 0) return Promise.resolve();
let [biggest, bigCount]:[Discord.VoiceChannel, number] = [null, -1];
for (const test of server.channels.getAll('type', 'voice')) {
const testCount = test.members.length -
(test.members.get(client.user.id) ? 1 : 0);
if (testCount < bigCount || testCount < 1) continue;
[biggest, bigCount] = [test, testCount];
}
// Join biggest, maybe leaving another
if (biggest) return biggest.join();
// Just leave
const conn = client.voiceConnections.get('server', server);
if (conn) return client.leaveVoiceChannel(conn.voiceChannel);
return Promise.resolve();
}