本文整理汇总了C#中Discord.DiscordClient.LeaveVoiceServer方法的典型用法代码示例。如果您正苦于以下问题:C# DiscordClient.LeaveVoiceServer方法的具体用法?C# DiscordClient.LeaveVoiceServer怎么用?C# DiscordClient.LeaveVoiceServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discord.DiscordClient
的用法示例。
在下文中一共展示了DiscordClient.LeaveVoiceServer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
if (!restart)
{
rpg = new KokoroBotRPG();
loadFiles();
}
else
{
restart = false;
}
{
DiscordClientConfig config = new DiscordClientConfig();
config.VoiceMode = DiscordVoiceMode.Outgoing;
config.VoiceBufferLength = 40;
var client = new DiscordClient(config);
//Display all log messages in the console
client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");
client.MessageReceived += async (s, e) =>
{
Console.WriteLine(e.Message.User.Name + ": " + e.Message.Text);
if (!e.Message.IsAuthor)
{
var currentChannel = e.Channel;
if (e.User.Id == 95543627391959040)
{
if (e.Message.Text == "-mute")
{
mute = !mute;
await client.SendMessage(currentChannel, "KokoroBot is now mute: " + mute.ToString());
}
else if (e.Message.Text == "-clear")
{
if (voiceclient != null)
voiceclient.ClearVoicePCM();
}
else if (e.Message.Text == "-save")
{
saveFiles();
await client.SendMessage(currentChannel, "I have saved everything :3");
}
else if (e.Message.Text == "-dc")
{
quit = true;
running = false;
}
else if (e.Message.Text == "-restart")
{
await client.SendMessage(currentChannel, "Cya on the other side :3");
restart = true;
running = false;
await client.Disconnect();
}
else if (e.Message.Text.StartsWith("-join"))
{
var channels = e.Server.Channels.Where((Channel chan) => {
return e.Message.Text.Substring(5).TrimStart(' ') == chan.Name && chan.Type == ChannelType.Voice; });
if (channels.Any())
{
var channel = channels.First();
Console.WriteLine("KokoroBot tries to join Channel: " + channel.Name);
voiceclient = await client.JoinVoiceServer(channel);
voiceserver = e.Message.Server;
}
}
else if (e.Message.Text == "-leave")
{
if (voiceclient != null)
{
voiceclient.ClearVoicePCM();
await client.LeaveVoiceServer(voiceserver);
voiceclient = null;
voiceserver = null;
}
}
}
else if (e.User.Name == "part")
{
await client.SendMessage(currentChannel, "I don't like you. B-b-baka. >.<");
return;
}
if (!mute) {
if (e.Message.Text.Length > 0)
{
string[] splitmessage = e.Message.Text.Split(' ');
if (splitmessage[0] == "-kardfacts")
{
if (splitmessage.Length > 2)
{
if (splitmessage[1] == "add")
{
try
{
string finalstr = "";
for (int i = 2; i < splitmessage.Length; i++)
{
if (i != 2)
finalstr += ' ' + splitmessage[i];
//.........这里部分代码省略.........