示例#1
0
        public void Initialize()
        {
            var config = Database.Load <DBLApiConfig>(DBLApiConfig.DocumentName());

            if (config == null)
            {
                //The document should be generated with the use of a command and not generated on demand.
                return;
            }

            if (config.APIKey == null)
            {
                Logger.Log("DiscordBots.org api key not set but a config was generated.", Discord.LogSeverity.Warning);
                return;
            }

            try
            {
                DBLApi = new ShardedDiscordNetDblApi(Client, config.APIKey);
                DBLApi?.CreateListener();
            }
            catch
            {
                //
            }
        }
示例#2
0
        public DBLApiConfig GetOrCreateConfig()
        {
            var config = Database.Load <DBLApiConfig>(DBLApiConfig.DocumentName());

            if (config == null)
            {
                config = new DBLApiConfig();
                Database.Store(config, DBLApiConfig.DocumentName());
            }

            return(config);
        }
示例#3
0
 public void SaveConfig(DBLApiConfig config)
 {
     Database.Store(config, DBLApiConfig.DocumentName());
 }