Beispiel #1
0
        public async void Start()
        {
            Logger.Warning("The CSF Discord Bot Core is a really unstable early version!");
            GatewayGetter gg = new GatewayGetter(token);

            try {
                Logger.Info("Requesting Gateway data...");
                GatewayGetter.GatewayResponse response = gg.GetGateway();
                Uri u = new Uri(response.url + "?format=json");

                int shard_count = response.shards;

                for (int i = 0; i < shard_count; i++)
                {
                    MainSocket socket = new MainSocket(u, token, i, shard_count);
                    foreach (Processor p in processors)
                    {
                        p.SetToken(token);
                        p.SetClient(this);
                        socket.AddProcessor(p);
                    }
                    shards.Add(socket);
                }

                foreach (MainSocket ms in shards)
                {
                    await ms.Connect();
                }

                started = true;
            } catch (Exception e) {
                Logger.Error($"Server startup failed: {e.Message}");
            }
        }