Beispiel #1
0
        public static void SerializeRaid(RaidTimer obj)
        {
            List <RaidTimer> objects = new List <RaidTimer>();

            if (File.Exists(raidPath))
            {
                Console.WriteLine("It exists");
                objects = DeSerializeObj();
            }
            if (obj == null)
            {
                return;
            }
            objects.Add(obj);
            try
            {
                XmlSerializer writer = new XmlSerializer(objects.GetType());



                System.IO.FileStream file = System.IO.File.Create(raidPath);

                writer.Serialize(file, objects);
                file.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to write to db: {0}", e.ToString());
            }
        }
Beispiel #2
0
        private void SetUpTimer(RaidTimer raid)
        {
            List <XmlTimeSpan> l = raid.time;

            foreach (var time in l)
            {
                DateTime current  = DateTime.Now;
                TimeSpan timeToGo = time - current.TimeOfDay;
                if (timeToGo < TimeSpan.Zero)
                {
                    return;
                }
                Console.WriteLine("The raid time is at: " + time);
                this.timer = new System.Threading.Timer(x =>
                {
                    this.RaidAlert("It totally works bro!", _client, "default");
                }, null, timeToGo, System.Threading.Timeout.InfiniteTimeSpan);
            }
        }
Beispiel #3
0
        public async Task MainAsync()
        {
            _client = new DiscordSocketClient();

            _client.Log             += Log;
            _client.MessageReceived += MessageReceived;

            string token = "NDExOTI4OTY5NjkzMTAyMDgx.DWEVRg.DOCw_fH4O-SZxjP60wkccdLjss4"; // Remember to keep this private!
            await _client.LoginAsync(TokenType.Bot, token);

            await _client.StartAsync();


            List <RaidTimer> raidList = new List <RaidTimer>();

            raidList = SaveRaid.DeSerializeObj();
            AddRaids(raidList);
            RaidTimer bd = new RaidTimer();

            bd.time.Add(new TimeSpan(1, 1, 1));

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }