Bot加入语音通道,然后立即离开Discord.Net

时间:2018-11-06 06:01:02

标签: c# .net audio discord discord.net

在Discord.Net 1.0.2中,我正在尝试制作一个可以在语音通道中播放youtube视频的机器人。问题是当僵尸程序加入时,僵尸程序立即离开。这是我的代码。

    [Command("play")]
    public async Task PlayMusic(string videourl)
    {
        #region Joining the channel
        SocketGuildUser user = Context.User as SocketGuildUser;
        if (user.VoiceState == null)
        {
            await Context.Channel.SendMessageAsync(":x: You aint' in a voice channel!");
            return;
        }
        ISocketAudioChannel channel = user.VoiceChannel;
        await channel.ConnectAsync();


        #endregion 
    }

我没有任何错误。作为奖励,我如何播放音频文件?

0 个答案:

没有答案
相关问题