using Discord; using Discord.WebSocket; using Kerobot.Services; using Npgsql; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace Kerobot { /// /// Kerobot main class, and the most accessible and useful class in the whole program. /// Provides an interface for any part of the program to call into all existing services. /// public partial class Kerobot { // Partial class: Services are able to add their own methods and properties to this class. // This is to prevent this file from having too many references to many different and unrelated features. private readonly InstanceConfig _icfg; private readonly DiscordSocketClient _client; /// /// Gets application instance configuration. /// internal InstanceConfig Config => _icfg; /// /// Gets the Discord client instance. /// public DiscordSocketClient DiscordClient => _client; internal Kerobot(InstanceConfig conf, DiscordSocketClient client) { _icfg = conf; _client = client; InitializeServices(); // and prepare modules here } private void InitializeServices() { throw new NotImplementedException(); } /// /// Returns an open NpgsqlConnection instance. /// /// /// If manipulating guild-specific information, this parameter sets the database connection's search path. /// internal async Task GetOpenNpgsqlConnectionAsync(ulong? guild) { string cs = _icfg.PostgresConnString; if (guild.HasValue) cs += ";searchpath=guild_" + guild.Value; var db = new NpgsqlConnection(cs); await db.OpenAsync(); return db; } } }