public MusicService(LavaConfig lavaConfig, LavaNode lavaNode, DiscordSocketClient client, DataService dataService) { _lavaConfig = lavaConfig; _lavaNode = lavaNode; _client = client; _dataService = dataService; }
public async Task OnReadyAsync() { LavaConfig config = new LavaConfig() { LogSeverity = LogSeverity.Verbose, }; await _lavaNode.ConnectAsync(); }
public DJService(LavaConfig lavaConfig, LavaNode lavaNode) { this.lavaConfig = lavaConfig; this.lavaNode = lavaNode; this.lavaNode.OnTrackEnded += OnTrackEndedAsync; this.lavaNode.OnTrackStuck += OnTrackStuckAsync; this.lavaNode.OnTrackException += OnTrackExceptionAsync; this.lavaNode.OnWebSocketClosed += OnWebSocketClosed; guildInfo = new ConcurrentDictionary <IGuild, DJGuildInfo>(); }
public LavaLinkService( LavaNode node, LavaConfig config, DiscordSocketClient client, ILoggingService logger) { _lavaNode = node; _config = config; _client = client; _logger = logger; }
/// <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); }
public MusicService(IServiceProvider services, IOptionsMonitor <Config> config) { _lavaSocketClient = services.GetRequiredService <LavaNode>(); _lavaConfig = services.GetRequiredService <LavaConfig>(); _discord = services.GetRequiredService <DiscordSocketClient>(); _logger = services.GetRequiredService <ILoggerService>(); _services = services; _config = config; Console.WriteLine($"{GetType().Name} initialized"); }
public AudioService(LavaConfig config, DiscordShardedClient _client) { if (_instance != null) { throw new InvalidOperationException("Cannot create another instance of a singleton"); } _audio = new LavaNode(_client, config); _instance = this; this._client = _client; _guildConfigs = new ConcurrentDictionary <ulong, GuildMusicConfig>(); _audio.OnTrackEnded += TrackFinish; _audio.OnLog += OnLog; }
public MusicService(DiscordSocketClient client, LogService logService, LavaConfig lavaConfig) { _client = client; _logService = logService; LavaNode = new LavaNode(_client, lavaConfig); _client.Ready += ClientReadyAsync; _client.UserVoiceStateUpdated += UserVoiceStateUpdatedAsync; LavaNode.OnLog += LogAsync; LavaNode.OnTrackEnded += OnTrackEndedAsync; LavaNode.OnTrackStuck += OnTrackStuckAsync; LavaNode.OnTrackException += OnTrackExceptionAsync; LavaNode.OnWebSocketClosed += OnWebSocketClosedAsync; }
public VictoriaPlayer(DiscordShardedClient client) { _client = client; _lavaClient = new Client(); _lavaClient.ClientException += OnClientException; _lavaConfig = new LavaConfig(); _lavaNode = new LavaNode(_client, _lavaConfig); _lavaNode.OnTrackEnded += OnTrackEnded; _lavaNode.OnTrackStuck += OnTrackStuck; _lavaNode.OnTrackException += OnTrackException; _lavaNode.OnWebSocketClosed += LavaNodeOnOnWebSocketClosed; }
public async Task SetupAsync() { _config = new ConfigService("./config.json"); await _client.LoginAsync(TokenType.Bot, _config.Config.BotToken); await _client.StartAsync(); _lavaConfig = new LavaConfig { Authorization = _config.Config.LavaLinkPassword, Hostname = _config.Config.LavaLinkHostname, Port = _config.Config.LavaLinkPort }; _client.Log += LogAsync; var services = SetupServices(); var commandHandler = services.GetRequiredService <CommandHandler>(); await commandHandler.SetupAsync(); await Task.Delay(-1); }
public async Task MainAsync() { if (!LoadBotDefinition()) { throw new Exception("No token provided."); } guildsDefinition = new GuildsDefinition(); client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Info, MessageCacheSize = 100 }); client.Log += Log; client.Ready += OnReadyAsync; lavaConfig = new LavaConfig(); lavaNode = new LavaNode(client, lavaConfig); reactionRoleService = new ReactionRoleService(client, guildsDefinition); commandService = new CommandService(); commandHandler = new CommandHandler(BuildServiceProvider(), client, commandService, botDefinition); await commandHandler.InstallCommandsAsync(); await client.LoginAsync(TokenType.Bot, token); await client.StartAsync(); await client.SetGameAsync(botDefinition.GetCurrent().status, null, ActivityType.Playing); // Block this task until the program is closed. await Task.Delay(-1); }
public async Task MainAsync(string[] args) { AppDomain.CurrentDomain.UnhandledException += async(sender, eventArgs) => { Console.ForegroundColor = ConsoleColor.Red; await ConsoleLogger.LogAsync($"Unhandled Exception: {(Exception) eventArgs.ExceptionObject}\n" + $"Inner Exception: {((Exception) eventArgs.ExceptionObject).InnerException}", LogLvl.ERROR); }; var config = new DiscordSocketConfig { MessageCacheSize = 200, AlwaysDownloadUsers = true, LogLevel = LogSeverity.Info, #if DEBUG TotalShards = 1 #else TotalShards = 5, #endif }; _client = new DiscordShardedClient(config); _client.Log += Log; var lavaConfig = new LavaConfig { EnableResume = true, LogSeverity = LogSeverity.Verbose, ReconnectAttempts = 10, SelfDeaf = true }; _lavaNode = new LavaNode(_client, lavaConfig); await SetupKaguya(); using (ServiceProvider services = new SetupServices().ConfigureServices(config, _client)) { try { GlobalPropertySetup(_botConfig); SetupTwitch(); DiscordEventLogger.InitLogger(); GuildLogger.InitializeGuildLogListener(); await TestDatabaseConnection(); _client = services.GetRequiredService <DiscordShardedClient>(); await services.GetRequiredService <CommandHandler>().InitializeAsync(); await _client.LoginAsync(TokenType.Bot, _botConfig.Token); await _client.StartAsync(); await _client.SetGameAsync($"v{ConfigProperties.Version}: Booting up!"); _client.ShardReady += async c => { if (!_lavaNode.IsConnected) { await _lavaNode.ConnectAsync(); } }; await InitializeTimers(AllShardsLoggedIn(_client, config)); _lavaNode.OnLog += async message => { await ConsoleLogger.LogAsync("[Kaguya Music]: " + message.Message, LogLvl.INFO); }; InitializeEventHandlers(); if (AllShardsLoggedIn(_client, config)) { ConfigProperties.LavaNode = _lavaNode; OsuBase.Client = new OsuClient(new OsuSharpConfiguration { ApiKey = _botConfig.OsuApiKey }); } // Keep the app running. await Task.Delay(-1); } catch (HttpException e) { await ConsoleLogger.LogAsync("Error when logging into Discord:\n" + "-Have you passed in the correct application arguments?\n" + $"-Is your token correct? Exception: {e.Message}", LogLvl.ERROR); Console.ReadLine(); } catch (Exception e) { await ConsoleLogger.LogAsync("Something really important broke!\n" + $"Exception: {e.Message}\n" + $"More information: {e}", LogLvl.ERROR); } } }
private async Task MainAsync() { await Data.InitYML(); await MySQL.Initialize(); if (!Multicraft.Initialize(Environment.GetEnvironmentVariable("SystemType"), BotType.Ja3farBot)) { Console.WriteLine("FALSE"); return; } _client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Debug, MessageCacheSize = 100, AlwaysDownloadUsers = true, ExclusiveBulkDelete = true }); _cmdService = new CommandService(new CommandServiceConfig { CaseSensitiveCommands = true, DefaultRunMode = RunMode.Async, LogLevel = LogSeverity.Info }); _lavaConfig = new LavaConfig { LogSeverity = LogSeverity.Debug, SelfDeaf = false }; _client.MessageReceived += Client_CommandHandler; _client.Ready += Client_Ready; _cmdService.CommandExecuted += SocialsExceptionHandler; _client.MessageReceived += Bot_CommandHandler; await _client.LoginAsync(TokenType.Bot, Config.Token); await _client.StartAsync(); _provider = new ServiceCollection() .AddSingleton(_client) .AddSingleton(_cmdService) .AddSingleton <InteractiveService>() .AddSingleton <LavaNode>() .AddSingleton(_lavaConfig) .AddSingleton <MusicService>() .AddSingleton <LoggerService>() .AddSingleton <EventHandlers>() .AddSingleton <LogEventHandlers>() .AddSingleton <SuggestionService>() .AddSingleton <AutomodService>() .AddSingleton <CustomVCService>() .AddSingleton <WebSocketService>() .BuildServiceProvider(); await _cmdService.AddModulesAsync(Assembly.GetEntryAssembly(), _provider); if (Config.Music) { await _provider.GetRequiredService <MusicService>().Initialize(); } await _provider.GetRequiredService <LoggerService>().Initialize(); await _provider.GetRequiredService <EventHandlers>().Initialize(); await _provider.GetRequiredService <LogEventHandlers>().Initialize(); await _provider.GetRequiredService <SuggestionService>().Initialize(); await _provider.GetRequiredService <AutomodService>().Initialize(); await _provider.GetRequiredService <CustomVCService>().Initialize(); _provider.GetRequiredService <WebSocketService>().Initialize(); await Task.Delay(-1); }