public static GlobalPreferences LoadFromFile(string instanceId) { var path = FilePath.Replace("{iId}", instanceId); if (File.Exists(path)) { var p = JsonConvert.DeserializeObject <GlobalPreferences>(File.ReadAllText(path)); return(p); } var prefs = new GlobalPreferences(instanceId); prefs.SavePreferences(); return(prefs); }
public DiscordBotFramework(IHost host, IConfiguration config, ILogger <DiscordBotFramework> logger, string cmdPrefix) { _host = host; _config = config; _logger = logger; CommandPrefix = cmdPrefix; Client = new DiscordSocketClient(); Commands = new CommandService(); R = new Random(); Preferences = GlobalPreferences.LoadFromFile(""); Preferences.SetValue("prefix", cmdPrefix); FollowUpContexts = new Dictionary <ulong, CommandFollowUpContext>(); Client.Ready += async() => { _logger.LogInformation("Discord bot is ready."); _logger.LogInformation("Logged in as: {0}", Client.CurrentUser); }; Client.MessageReceived += Client_MessageReceived; }
public SettingsDictionary(GlobalPreferences prefs) : base() { globalPrefs = prefs; }
public ServerPreferences(GlobalPreferences prefs) { config = new Dictionary <ulong, SettingsDictionary>(); globalPrefs = prefs; }