Exemplo n.º 1
0
 private Task SocketClientOnReady()
 {
     // TODO figure out if this is fine or if we should use IsConnected to check
     _lavaNode.ConnectAsync();
     _socketClient.Ready -= SocketClientOnReady;
     return(Task.CompletedTask);
 }
Exemplo n.º 2
0
 private async Task OnReady()
 {
     if (!_lavaNode.IsConnected)
     {
         await _lavaNode.ConnectAsync();
     }
 }
Exemplo n.º 3
0
 private async Task ClientReadyAsync()
 {
     if (!_lavaSocketClient.IsConnected)
     {
         await _lavaSocketClient.ConnectAsync();
     }
 }
Exemplo n.º 4
0
        // Initializes Discord.Net
        private async Task Start()
        {
            _client  = new DiscordSocketClient();
            _handler = new MessageHandler(_client);
            lavaNode = new LavaNode(_client, new LavaConfig {
                Authorization     = "youshallnotpass",
                Hostname          = "localhost",
                Port              = 2333,
                ReconnectAttempts = 3,
                ReconnectDelay    = TimeSpan.FromSeconds(5)
            });

            await _handler.Init();

            await _client.LoginAsync(TokenType.Bot, _token);

            await _client.StartAsync();

            _client.Ready += async() => {
                if (!lavaNode.IsConnected)
                {
                    await lavaNode.ConnectAsync();
                }
            };
            lavaNode.OnTrackEnded   += MusicModule.OnTrackEnded;
            lavaNode.OnTrackStarted += MusicModule.OnTrackStarted;

            await Task.Delay(-1);
        }
Exemplo n.º 5
0
        private async Task OnReady()
        {
            if (!lavaNode.IsConnected)
            {
                await lavaNode.ConnectAsync();
            }

            if (data.Count <= 0)
            {
                return;
            }

            foreach (KeyValuePair <ulong, LavalinkData> data in data)
            {
                await lavaNode.LeaveAsync(data.Value.VoiceChannel);

                NixPlayer player = await CreatePlayerForGuildAsync(
                    data.Value.VoiceChannel.Guild,
                    data.Value.VoiceChannel,
                    data.Value.TextChannel);

                players.TryAdd(data.Key, player);
                await player.PlayAsync(data.Value);
            }

            data.Clear();
        }
Exemplo n.º 6
0
 private async Task ClientReady()
 {
     if (!_lavaNode.IsConnected)
     {
         _lavaConfig.LogSeverity = LogSeverity.Info;
         await _lavaNode.ConnectAsync();
     }
 }
Exemplo n.º 7
0
        private async Task OnReadyAsync()
        {
            await _lavaNode.ConnectAsync();

            await _client.SetActivityAsync(defaultGame);

            await _client.SetStatusAsync(UserStatus.AFK);
        }
Exemplo n.º 8
0
 private async Task OnReady()
 {
     if (!_node.IsConnected)
     {
         await _node.ConnectAsync();
     }
     System.Console.WriteLine($"Connected as {_client.CurrentUser.Username}#{_client.CurrentUser.Discriminator}");
 }
Exemplo n.º 9
0
 private async Task OnReadyAsync()
 {
     _logger.LogDebug("Battle Control Online");
     if (!_lavaNode.IsConnected)
     {
         await _lavaNode.ConnectAsync();
     }
 }
Exemplo n.º 10
0
 private async Task OnReadyAsync()
 {
     if (!_lavaNode.IsConnected)
     {
         await _lavaNode.ConnectAsync();
     }
     await _client.SetGameAsync("use //help to see my commands", null, ActivityType.Playing);
 }
Exemplo n.º 11
0
 /// <summary>Connect to lavalink node.
 /// </summary>
 private async Task Client_Ready()
 {
     //Connect to Lavalink node if we don't have a connection
     if (!_lavaNode.IsConnected)
     {
         await _lavaNode.ConnectAsync();
     }
 }
Exemplo n.º 12
0
 private async Task ClientReady()
 {
     // Avoid calling ConnectAsync again if it's already connected
     // (It throws InvalidOperationException if it's already connected).
     if (!_lavaNode.IsConnected)
     {
         await _lavaNode.ConnectAsync();
     }
 }
Exemplo n.º 13
0
 private async Task _client_ShardReady(DiscordSocketClient arg)
 {
     if (!_lavaNode.IsConnected)
     {
         _lavaNode.ConnectAsync();
     }
     _chomusukeTimer.StartTimer();
     _autoLewdTimer.StartTimer();
 }
Exemplo n.º 14
0
        public async Task OnReadyAsync()
        {
            LavaConfig config = new LavaConfig()
            {
                LogSeverity = LogSeverity.Verbose,
            };

            await _lavaNode.ConnectAsync();
        }
Exemplo n.º 15
0
        private static async Task OnReady()
        {
            if (!_lavaNode.IsConnected)
            {
                await _lavaNode.ConnectAsync();
            }

            Console.WriteLine($"Connected as {_client.CurrentUser.Username}#{_client.CurrentUser.Discriminator}");
            await Task.CompletedTask;
        }
Exemplo n.º 16
0
        private async Task ReadyAsync()
        {
            if (!_lavaNode.IsConnected)
            {
                _lavaNode.OnLog += LogAsync;
                await _lavaNode.ConnectAsync();
            }

            Console.WriteLine($"Connected as -> {_client.CurrentUser.Username}");
        }
Exemplo n.º 17
0
        private async Task OnReady(DiscordSocketClient client)
        {
            try {
                await _lavaNode.ConnectAsync();

                _logger.LogInformation("Lava should be connected");
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// The Ready event indicates that the client has opened a connection and it is now safe to access the cache.
        /// </summary>
        private async Task <Task> Ready()
        {
            LavaConfig conf = new LavaConfig();

            _lavaNode = new LavaNode(discordclient, conf);
            _lavaNode.OnTrackEnded += OnTrackEndedAsync;
            await _lavaNode.ConnectAsync();

            Console.WriteLine(discordclient.CurrentUser + " is connected!");
            return(Task.CompletedTask);
        }
Exemplo n.º 19
0
        private async Task OnReadyAsync()
        {
            // Avoid calling ConnectAsync again if it's already connected
            // (It throws InvalidOperationException if it's already connected).
            if (!_lavaNode.IsConnected)
            {
                await _lavaNode.ConnectAsync();
            }

            // Other ready related stuff
        }
Exemplo n.º 20
0
 public Task OnReadyAsync()
 {
     if (!_instanceOfLavaNode.IsConnected)
     {
         _instanceOfLavaNode.ConnectAsync();
         _logger.LogInformation("Connected to LavaLink");
     }
     _logger.LogInformation($"Connected as -> [{_discord.CurrentUser}] :)");
     _logger.LogInformation($"We are on [{_discord.Guilds.Count}] servers");
     return(Task.CompletedTask);
 }
Exemplo n.º 21
0
        private async Task InitializeServices()
        {
            await _services.GetRequiredService <CommandHandlingService>().InitializeAsync();

            LavaNode lavaNode = _services.GetRequiredService <LavaNode>();

            if (!lavaNode.IsConnected)
            {
                await lavaNode.ConnectAsync();
            }
            lavaNode.OnLog += Log;
        }
Exemplo n.º 22
0
        /// <summary>
        ///     Connect to the player.
        /// </summary>
        public async Task Connect()
        {
            if (_lavaNode.IsConnected)
            {
                return;
            }
            Console.WriteLine("Connection Victoria Player...");
            try
            {
                await _lavaNode.ConnectAsync();

                if (_lavaNode.IsConnected)
                {
                    Console.WriteLine("Connected to lavalink.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Failed to connect to victoria node. Reason {e.Message}");
            }
        }
Exemplo n.º 23
0
        public async Task InitializeAsync()
        {
            LavaNode = new LavaNode(Client, config: new LavaConfig()
            {
                Hostname      = Config.Lavalink.Hostname,
                Port          = (ushort)Config.Lavalink.Port,
                Authorization = Config.Lavalink.Password,
                SelfDeaf      = true
            });

            await LavaNode.ConnectAsync();
        }
Exemplo n.º 24
0
        private async Task OnReady()
        {
            int users = _client.Guilds.Sum(g => g.MemberCount);
            await _client.SetGameAsync($"/help with {users} users", null, type : ActivityType.Listening);

            await _client.DownloadUsersAsync(_client.Guilds);

            if (!_lavaNode.IsConnected)
            {
                await _lavaNode.ConnectAsync();
            }
        }
Exemplo n.º 25
0
        /* Used when the Client Fires the ReadyEvent. */
        private async Task ReadyAsync()
        {
            try
            {
                await _lavaNode.ConnectAsync();

                await _client.SetGameAsync(GlobalData.Config.GameStatus);
            }
            catch (Exception ex)
            {
                await LoggingService.LogInformationAsync(ex.Source, ex.Message);
            }
        }
Exemplo n.º 26
0
 // Used when the Client Fires the ReadyEvent.
 private async Task ReadyAsync()
 {
     try
     {
         if (!_lavaNode.IsConnected)
         {
             await _lavaNode.ConnectAsync();
         }
         await _client.SetActivityAsync(new Game (ConfigData.Config.Status, ConfigData.Config.Activity));
     }
     catch (Exception ex)
     {
         await LogService.LogInfoAsync(ex.Source, ex.Message);
     }
 }
Exemplo n.º 27
0
        private static async Task OnReady()
        {
            try
            {
                await _lavaNode.ConnectAsync();
            }

            catch (Exception ex)
            {
                throw ex;
            }

            Console.WriteLine($"[{DateTime.Now}]\t(READY)\tBot is ready.");
            await _client.SetStatusAsync(UserStatus.Online);

            await _client.SetGameAsync(name : $"Komutlar: yardım", streamUrl : "https://www.twitch.tv/Duthris", ActivityType.Streaming);
        }
Exemplo n.º 28
0
        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}!");
        }
Exemplo n.º 29
0
        private async Task OnReady()
        {
            _logger.LogInformation("Connected as {username}#{discriminator}", _client.CurrentUser.Username, _client.CurrentUser.Discriminator);

            if (_settings.EnableLavaLink && !_lavaNode.IsConnected)
            {
                _logger.LogDebug("Connecting to Lavalink");
                await _lavaNode.ConnectAsync();
            }

            var settings = await _discordBotSettingsRepository.Get();

            await _client.SetGameAsync(settings.Game);

            Console.WriteLine("SocketClient is ready");
            Console.WriteLine($"Connected as {_client.CurrentUser.Username}#{_client.CurrentUser.Discriminator}");

            if (ShowJoinAndPartMessages)
            {
                foreach (var guild in _client.Guilds)
                {
                    foreach (var channel in guild.Channels)
                    {
                        if (channel.Name.ToLowerInvariant() == "bot" || channel.Name.ToLowerInvariant().Contains("bot-spam"))
                        {
                            if (channel != null && channel is SocketTextChannel textChannel)
                            {
                                var builder = new EmbedBuilder()
                                              .WithThumbnailUrl(_client.CurrentUser.GetAvatarUrl() ?? _client.CurrentUser.GetDefaultAvatarUrl())
                                              .WithDescription($"{_settings.BotName} Starting\nMIT License Copyright(c) 2021 JoyfulReaper\n{_settings.BotWebsite}")
                                              .WithColor(await _servers.GetEmbedColor(guild.Id))
                                              .WithCurrentTimestamp();

                                var embed = builder.Build();
                                await textChannel.SendMessageAsync(null, false, embed);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 30
0
        private async Task OnClientReady()
        {
            // Set the bots status
            await _client.SetActivityAsync(new Game($"commands in {_client.Guilds.Count} guilds || $help", ActivityType.Listening, ActivityProperties.None));

            if (!_lavaNode.IsConnected)
            {
                await _lavaNode.ConnectAsync();
            }
            Console.WriteLine(_lavaNode.IsConnected);


            // Cache guild members upon startup
            _ = Task.Run(async() =>
            {
                Console.WriteLine("loading guilds....");
                await Task.WhenAll(_client.Guilds.Select(g => g.DownloadUsersAsync()));
                int count = _client.Guilds.Sum(g => g.Users.Count);
                Console.WriteLine($"done loading guilds, cached {count} users");
            });
        }