public DeviCommandModule(DeviSettingStore settings, DeviEmojiMap emoji_map, DeviDongerMap donger_map, DeviGuildEmojiMap guild_emoji, DeviUtilities utils) { this.Settings = settings; this.EmojiMap = emoji_map; this.Dongers = donger_map; this.GuildEmoji = guild_emoji; this.Utilities = utils; }
private static async Task Order66() { KeyManager = new KeyManager("keystore.json"); if (!KeyManager.HasKey("pgmain")) { KeyManager.AddKey("pgmain", 256); } var l = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); GuildEmoji = new DeviGuildEmojiMap(new Dictionary <string, string>()); var stx = Path.Combine(l, "devi.json"); var emx = Path.Combine(l, "emoji.json"); var dgx = Path.Combine(l, "donger.json"); if (File.Exists(stx) && File.Exists(emx) && File.Exists(dgx)) { stx = File.ReadAllText(stx, new UTF8Encoding(false)); Settings = JsonConvert.DeserializeObject <DeviSettingStore>(stx); } else { throw new FileNotFoundException("Unable to load configuration file (devi.json)!"); } DatabaseClient = new DeviDatabaseClient(Settings.DatabaseSettings, KeyManager); await DatabaseClient.PreconfigureAsync(); if (File.Exists(emx)) { emx = File.ReadAllText(emx, new UTF8Encoding(false)); var edict = JsonConvert.DeserializeObject <Dictionary <string, string> >(emx); EmojiMap = new DeviEmojiMap(edict); } else { EmojiMap = new DeviEmojiMap(new Dictionary <string, string>()); } if (File.Exists(dgx)) { dgx = File.ReadAllText(dgx, new UTF8Encoding(false)); Dongers = JsonConvert.DeserializeObject <DeviDongerMap>(dgx); Dongers.HookAliases(); } else { Dongers = new DeviDongerMap() { Dongers = new Dictionary <string, string>(), Aliases = new Dictionary <string, List <string> >() }; } Utilities = new DeviUtilities(); Http = new HttpClient(); var discord = new DiscordClient(new DiscordConfig() { LogLevel = LogLevel.Debug, Token = Settings.Token, TokenType = TokenType.User, MessageCacheSize = Settings.CacheSize, AutomaticGuildSync = false }); DeviClient = discord; var depb = new DependencyCollectionBuilder(); var deps = depb.AddInstance(Settings) .AddInstance(EmojiMap) .AddInstance(Dongers) .AddInstance(GuildEmoji) .AddInstance(DatabaseClient) .AddInstance(Utilities) .AddInstance(Http) .AddInstance(Settings.CryptoSettings) .AddInstance(KeyManager) .Add <CryptonatorApiClient>() .Add <NanopoolApiClient>() .Build(); CommandsNextUtilities.RegisterConverter(new CryptoCurrencyCodeConverter()); var commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = Settings.Prefix, SelfBot = true, EnableDefaultHelp = false, EnableMentionPrefix = false, Dependencies = deps }); DeviCommands = commands; DeviCommands.CommandErrored += DeviCommands_CommandErrored; DeviCommands.RegisterCommands <DeviCommandModule>(); DeviCommands.RegisterCommands <DeviLogManagementModule>(); DeviCommands.RegisterCommands <DeviCryptomarketCommands>(); DeviMessageTracker = new List <DiscordMessage>(); discord.GuildAvailable += Discord_GuildAvailable; discord.MessageCreated += Discord_MessageReceived; discord.MessageUpdated += Discord_MessageUpdate; discord.MessageDeleted += Discord_MessageDelete; discord.MessagesBulkDeleted += Discord_MessageBulkDelete; discord.Ready += Discord_Ready; discord.DebugLogger.LogMessageReceived += Discord_Log; discord.MessageReactionAdded += Discord_ReactionAdded; discord.MessageReactionRemoved += Discord_ReactionRemoved; discord.ClientErrored += Discord_ClientError; await discord.ConnectAsync(); await Task.Delay(-1); }