Exemplo n.º 1
0
        internal DiscordManager(BuildOption option) : base(option.LogLevel)
        {
            Manager = this;
            Client  = option.Client;
            Prefix  = option.Prefix;
            if (Client == null)
            {
                var socketConfig = option.SocketConfig ?? new DiscordSocketConfig
                {
                    MessageCacheSize = 100, TotalShards = option.Shards
                };
                if (option.Shards.HasValue)
                {
                    Client = new DiscordShardedClient(option.ShardIds, socketConfig);
                }
                else
                {
                    Client = new DiscordSocketClient(socketConfig);
                }
            }

            if (option.Shards.HasValue)
            {
                Client.SetActivityAsync(option.Game).ConfigureAwait(false);
            }
            Client.SetStatusAsync(option.BotStatus).ConfigureAwait(false);

            if (option.UseConfig)
            {
                LoaderConfig.Path = option.Path;
                _configManager    = new ConfigManager();
                _configManager.Load().ConfigureAwait(false);
                var config = GetConfig <Common>();
                Prefix = config.Prefix;
            }

            if (option.UseObjectService)
            {
                _objectService = new ObjectService();
            }

            if (option.CommandConfig != null)
            {
                _clientLogger.DebugAsync("Load CommandModules...");
                CommandManager.LoadCommands(option.CommandConfig.HelpArg);
                Client.MessageReceived += option.CommandConfig.CommandFunc ?? ClientOnMessageReceived;
            }
        }
 public virtual Task SetStatusAsync(UserStatus status)
 {
     return(_baseSocketClient.SetStatusAsync(status));
 }