예제 #1
0
        private BotSavedInfo Load()
        {
            DirectoryInfo dinfo = null;
            FileInfo      file  = null;

            try
            {
                dinfo = new DirectoryInfo(folder);
                file  = dinfo.GetFiles("BotInfo_Railgun.txt").ToList()[0];
            }
            catch
            {
                dinfo = new DirectoryInfo(folder2);
                file  = dinfo.GetFiles("BotInfo_Railgun.txt").ToList()[0];
            }

            StreamReader fileInfo       = file.OpenText();
            string       fileInfoString = fileInfo.ReadToEnd();

            var resp = fileInfoString;

            BotSavedInfo response = null;

            response = JsonConvert.DeserializeObject <BotSavedInfo>(resp);

            fileInfo.Close();

            if (response == null)
            {
                response = new BotSavedInfo();
            }

            return(response);
        }
예제 #2
0
        public async Task MainAsync()
        {
            _client = new DiscordSocketClient();

            _client.Log             += Log;
            _client.MessageReceived += MessageReceived;
            _client.ReactionAdded   += ReactTimeAdd;
            _client.ReactionRemoved += ReactTimeDelete;

            //_client.MessageUpdated += MessageUpdate;


            // Remember to keep token private or to read it from an
            // external source! In this case, we are reading the token
            // from an environment variable. If you do not know how to set-up
            // environment variables, you may find more information on the
            // Internet or by using other methods such as reading from
            // a configuration.

            if (first)
            {
                var handle = GetConsoleWindow();
                //ShowWindow(handle, SW_HIDE);

                n = new NotifyIcon();
                //n.Icon = Resources.weather;
                n.Text    = "Railgun Running (Click for Console)";
                n.Visible = true;

                //await Application.Run();

                botssaves = Load();

                first = false;
            }

            await _client.LoginAsync(TokenType.Bot, botssaves.auth);

            await _client.StartAsync();

            _client.GuildAvailable += TestGUI;

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