Exemple #1
0
 /// <summary>
 ///     Disconnect from the player.
 /// </summary>
 public async Task Disconnect()
 {
     if (!_lavaNode.IsConnected)
     {
         return;
     }
     await _lavaNode.DisconnectAsync();
 }
        public async Task LavaLink([Summary("start or stop lavalink")] string enable = null)
        {
            await Context.Channel.TriggerTypingAsync();

            _logger.LogInformation("{username}#{discriminator} executed lavalink ({option}) on {server}/{channel}",
                                   Context.User.Username, Context.User.Discriminator, enable, Context.Guild?.Name ?? "DM", Context.Channel.Name);

            if (enable == null)
            {
                await ReplyAsync("LavaLink is " + (LavaLinkHelper.isLavaLinkRunning() ? "" : "not") + " running.");

                return;
            }

            if (enable.ToLowerInvariant() == "start")
            {
                LavaLinkHelper.StartLavaLink();
                await Task.Delay(5000);

                if (!_lavaNode.IsConnected)
                {
                    await _lavaNode.ConnectAsync();
                }
            }
            else if (enable.ToLowerInvariant() == "stop")
            {
                if (_lavaNode.IsConnected)
                {
                    await _lavaNode.DisconnectAsync();
                }

                LavaLinkHelper.StopLavaLink();
            }
            else
            {
                await ReplyAsync("Would you like to `start` or `stop` lavalink?");

                return;
            }

            await Context.Channel.SendEmbedAsync("Lava Link", $"Lavalink was {(enable.ToLowerInvariant() == "start" ? "started" : "stopped")}!",
                                                 ColorHelper.GetColor(await _servers.GetServer(Context.Guild)));

            await _servers.SendLogsAsync(Context.Guild, "Lavalink", $"Lavalink was {(enable.ToLowerInvariant() == "start" ? "started": "stopped")} by {Context.User.Mention}!");
        }
Exemple #3
0
        public async Task ShutdownAsync()
        {
            var message = await ReplyAsync("Do you really want to shut the bot down?");

            var emote = new Emoji("✅");
            await message.AddReactionAsync(emote);

            message.WaitForReaction(Context, emote, async() =>
            {
                await message.DeleteAsync();
                await Context.Message.DeleteAsync();
                await Context.Client.StopAsync();

                await _audioService.Dispose();
                if (_lavaNode.IsConnected)
                {
                    await _lavaNode.DisconnectAsync();
                }
            });
        }
Exemple #4
0
        public async Task Leave()
        {
            if (_player == null)
            {
                await ReplyAsync("Player not connected to any voice channel!");

                return;
            }
            await _node.DisconnectAsync(Context.Guild.Id);

            _player = _node.GetPlayer(Context.Guild.Id);
        }
        public async Task LeaveAsync()
        {
            var voiceState = Context.User as IVoiceState;

            if (voiceState?.VoiceChannel == null)
            {
                await ReplyAsync("You must be connected to a voice channel!");

                return;
            }
            try
            {
                await _lavaNode.DisconnectAsync();
                await ReplyAsync($"left {voiceState.VoiceChannel.Name}");
            }
            catch (Exception e)
            {
                await ReplyAsync(e.Message);
            }
        }