コード例 #1
0
        private void BuildServices(IServiceCollection services)
        {
            Global.Client    = new DiscordSocketClient(SocketEntity.GetDefault());
            Global.WebClient = OriWebClient.Default;

            services
            .AddSingleton <DataContainer>()
            //.AddSingleton(new LockedDblWrapper())
            //.AddSingleton(new DiscordShardedClient(new int[] {0}, SocketEntity.GetDefault()))
            .AddSingleton(new DiscordSocketClient(SocketEntity.GetDefault()))
            .AddSingleton(new CommandService(CommandEntity.GetDefault()))
            .AddSingleton(new AudioDependency())
            .AddSingleton(new CancellationTokenSource())
            .AddSingleton <DynamicManager>()
            //.AddSingleton<EventDependency>()
            .AddSingleton <NetworkManager>()
            .AddSingleton <ConsoleDependency>()
            .AddSingleton <AudioService>()
            .AddSingleton <InsultService>()
            .AddSingleton <StatusService>()
            .AddSingleton <GuildPrefUtility>()
            .AddSingleton <Exceptions>()
            //.AddSingleton<EventLogger>()
            .AddSingleton <Random>()
            .AddSingleton(Configuration);
        }
コード例 #2
0
        public void AddSingletonsToService(IServiceCollection collection)
        {
            Global.Client    = new DiscordSocketClient(SocketEntity.GetDefault());
            Global.WebClient = OriWebClient.Default;

            LockedDblWrapper dblWrapper = new LockedDblWrapper(Global.Client, Config["tokens:dbl"]);

            collection
            .AddSingleton <DataContainer>()                               // Where all data is stored.
            //.AddSingleton(new DiscordSocketClient(SocketEntityW.GetDefault())) // Orikivo's required boot.
            .AddSingleton(new CommandService(CommandEntity.GetDefault())) // Orikivo's command information.
            .AddSingleton <NetworkManager>()                              // Controls Discord connection.
            //.AddSingleton<EventLogger>() // Controls events that occur on Orikivo.
            .AddSingleton(Config);                                        // All of the passwords for public services.
        }