本文整理汇总了C#中Discord.DiscordClient.FindChannels方法的典型用法代码示例。如果您正苦于以下问题:C# DiscordClient.FindChannels方法的具体用法?C# DiscordClient.FindChannels怎么用?C# DiscordClient.FindChannels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discord.DiscordClient
的用法示例。
在下文中一共展示了DiscordClient.FindChannels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Install
public void Install(ModuleManager manager)
{
_manager = manager;
_client = manager.Client;
manager.CreateCommands("", group =>
{
group.CreateCommand("radio")
.Description("connects to a voice channel and plays random music")
.Parameter("Channel name")
.Do(async e =>
{
var channel = _client.FindChannels(e.Server, e.Args[0], ChannelType.Voice).FirstOrDefault();
/*try
{
var voice = await _client.JoinVoiceServer(channel);
await Task.Run(() =>
{
var random = new Random();
var files = Directory.GetFiles(@"D:\Shared\Music", "*.mp3").OrderBy(x => random.Next()).ToArray();
var outFormat = new WaveFormat(48000, 16, 1);
int blockSize = outFormat.AverageBytesPerSecond / 5; //200ms
byte[] buffer = new byte[blockSize];
foreach (var file in files)
{
using (var mp3Reader = new MediaFoundationReader(file))
using (var resampler = new MediaFoundationResampler(mp3Reader, outFormat) { ResamplerQuality = 60 })
{
int byteCount;
while ((byteCount = resampler.Read(buffer, 0, blockSize)) > 0)
voice.SendVoicePCM(buffer, byteCount);
}
}
});
await voice.WaitVoice();
}
catch (OperationCanceledException) { }
finally { await _client.LeaveVoiceServer(channel.Server); }*/
});
});
}