bool Profile_Setup_IsCompleted = false;                            ///make sure if the setup if completed so when its closed it opens MainWindow
        public DA_Startup()
        {
            InitializeComponent();
            AppVersionLabel0.Content = "YPBBT " + AppVersion;
            AppVersionLabel1.Content = "YPBBT " + AppVersion;
            bool App_isalready_opend = false;

            this.Visibility = Visibility.Hidden;
            if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1)///Check if the application is already opend
            {
                if (File.Exists(System.IO.Directory.GetCurrentDirectory() + "/Resources/DA_Profile"))
                {
                    string   lines           = File.ReadAllText(System.IO.Directory.GetCurrentDirectory() + "/Resources/DA_Profile");//read Profile File
                    string[] RefferalsFilter = lines.Split('|');
                    Load_Language_File(RefferalsFilter[0].ToString());
                }
                else
                {
                    Load_Language_File();
                }
                App_isalready_opend = true;
                this.Visibility     = Visibility.Hidden;
                ErrorMessageBox emb = new ErrorMessageBox(LanguageLinesCollection[23].ToString(), LanguageLinesCollection[24].ToString(), LanguageLinesCollection[25].ToString(), LanguageLinesCollection[14].ToString());
                emb.MB_typeYN_DA_Startup(LanguageLinesCollection[21].ToString(), LanguageLinesCollection[22].ToString(), 1, this);
                emb.Show();
            }
            Run_Profile_Setup(App_isalready_opend);
        }
示例#2
0
        public async void GetDiscordData(DA_MainWindow MainWindow)
        {
            Public_MainWindow = MainWindow;
            try
            {
                var bc = new BrushConverter();
                Application.Current.Dispatcher.Invoke((Action)(() => {
                    Public_MainWindow.DiscordBotConnectionStatusLabel.Foreground = (Brush)bc.ConvertFrom("#FFF1F1F1");
                    Public_MainWindow.DiscordBotConnectionStatusLabel.Content = Public_MainWindow.LanguageCollection[6].ToString();//"Connecting...";
                    if (Public_MainWindow.discord.ConnectionState == ConnectionState.Connected)
                    {
                        Public_MainWindow.Processing_Status(false, "Reconnecting Bot...");
                    }
                    else
                    {
                        Public_MainWindow.Processing_Status(false, "Connecting Bot...");
                    }
                }));
                await Public_MainWindow.discord.LoginAsync(TokenType.Bot, Public_MainWindow.Token);

                await Public_MainWindow.discord.StartAsync();

                System.Threading.Thread.Sleep(2000);

                Application.Current.Dispatcher.Invoke((Action)(() => {
                    if (Public_MainWindow.DiscordBotConnectionStatusLabel.Content.ToString() == Public_MainWindow.LanguageCollection[6].ToString())
                    {
                        Public_MainWindow.DiscordBotConnectionStatusLabel.Foreground = (Brush)bc.ConvertFrom("#FF669174");
                        Public_MainWindow.DiscordBotConnectionStatusLabel.Content = Public_MainWindow.LanguageCollection[8].ToString();//"Connected";
                        Public_MainWindow.Processing_Status(true, "Bot is Connected.");
                    }
                }));
            }
            catch (Exception s)
            {
                if (s is Discord.Net.HttpException)
                {
                    await Public_MainWindow.discord.StopAsync();

                    Application.Current.Dispatcher.Invoke((Action)(() => {
                        ErrorMessageBox emb = new ErrorMessageBox(Public_MainWindow.LanguageCollection[119].ToString(), Public_MainWindow.LanguageCollection[120].ToString(), Public_MainWindow.LanguageCollection[121].ToString(), Public_MainWindow.LanguageCollection[122].ToString());
                        emb.MB_typeOK(Public_MainWindow.LanguageCollection[108].ToString(), s.Message + Environment.NewLine + Environment.NewLine + Public_MainWindow.LanguageCollection[109].ToString(), Public_MainWindow);
                        emb.Show();
                        Public_MainWindow.IsEnabled = false;
                    }));
                }
                var bc = new BrushConverter();
                Application.Current.Dispatcher.Invoke((Action)(() => {
                    Public_MainWindow.DiscordBotConnectionStatusLabel.Foreground = (Brush)bc.ConvertFrom("#FFBB3D3D");
                    Public_MainWindow.DiscordBotConnectionStatusLabel.Content = Public_MainWindow.LanguageCollection[7].ToString();//"Connection ERROR!";
                    Public_MainWindow.Processing_Status(true, "Failed to connect Bot.", true);
                }));
                /*StartPosting();*/
            }
        }
示例#3
0
        public async void StartPosting(DA_MainWindow MainWindow)// purge discord channel and start posting
        {
            Public_MainWindow = MainWindow;
            if (Public_MainWindow.ServerID != 0)
            {
                try
                {
                    var bc = new BrushConverter();
                    try
                    {
                        Application.Current.Dispatcher.Invoke((Action)(() => {
                            Public_MainWindow.DiscordBotConnectionStatusLabel.Foreground = (Brush)bc.ConvertFrom("#FFF1F1F1");
                            Public_MainWindow.DiscordBotConnectionStatusLabel.Content = Public_MainWindow.LanguageCollection[6].ToString();//"Connecting...";
                        }));
                        await Public_MainWindow.discord.LoginAsync(TokenType.Bot, Public_MainWindow.Token);

                        await Public_MainWindow.discord.StartAsync();

                        System.Threading.Thread.Sleep(1000);
                    }
                    catch (Exception)
                    {
                        Application.Current.Dispatcher.Invoke((Action)(() => {
                            Public_MainWindow.DiscordBotConnectionStatusLabel.Foreground = (Brush)bc.ConvertFrom("#FFBB3D3D");
                            Public_MainWindow.DiscordBotConnectionStatusLabel.Content = Public_MainWindow.LanguageCollection[7].ToString();//"Connection ERROR!";
                        }));
                    }

                    if (Public_MainWindow.discord.ConnectionState == Discord.ConnectionState.Connected)
                    {
                        var guild = Public_MainWindow.discord.GetGuild(Public_MainWindow.ServerID);
                        SocketTextChannel channel = guild.GetTextChannel(Public_MainWindow.Main_BotChannel_ID);

                        var messages = await channel.GetMessagesAsync(100).FlattenAsync(); //defualt is 100

                        System.Threading.Thread.Sleep(2000);
                        await(channel as SocketTextChannel).DeleteMessagesAsync(messages);
                        var    embed1    = new EmbedBuilder();
                        string ANmessage = "";
                        Application.Current.Dispatcher.Invoke((Action)(() => {
                            string[] pbu = Public_MainWindow.publicbossUrl.Split('|');
                            string[] bnu = Public_MainWindow.CbossNameLabel.Content.ToString().Split('&');

                            if (Public_MainWindow.CbossNameLabel.Content.ToString().Contains("&"))
                            {
                                ANmessage = Public_MainWindow.LanguageCollection[123].ToString() + Environment.NewLine + "[" + bnu[0] + "](" + pbu[0] + ")" + " <---" + Public_MainWindow.LanguageCollection[85].ToString() + Environment.NewLine + "[" + bnu[1] + "](" + pbu[1] + ")" + " <---" + Public_MainWindow.LanguageCollection[85].ToString();
                            }
                            else
                            {
                                ANmessage = Public_MainWindow.LanguageCollection[123].ToString() + Environment.NewLine + "[" + bnu[0] + "](" + pbu[0] + ")" + " <---" + Public_MainWindow.LanguageCollection[85].ToString();
                            }
                            embed1 = new EmbedBuilder
                            {
                                Title = Public_MainWindow.CbossNameLabel.Content.ToString() /* + " <---" + LanguageCollection[87].ToString()*/,
                                ImageUrl = Public_MainWindow.publicNbossimage,
                                Color = Discord.Color.LightGrey,
                                //Url = publicbossUrl,
                                Description = ANmessage
                            };
                        }));
                        //Emoji emj = new Emoji("<:download1:832276391789199430>");
                        //var s = guild.Emotes;
                        //var exampleFooter = new EmbedFooterBuilder().WithText(
                        //      "Reaction 1" + " 0️⃣ " + Environment.NewLine
                        //    + "Reaction 2" + Environment.NewLine
                        //    + "Reaction 3" + Environment.NewLine);
                        //embed1.WithFooter(exampleFooter);


                        var BossImage = await channel.SendMessageAsync("", false, embed1.Build());

                        var AlertChannel = guild.TextChannels.FirstOrDefault(ch => ch.Id == Public_MainWindow.Alert_BotChannel_ID);
                        var Alert_Embed  = new EmbedBuilder
                        {
                            Title        = "YPBBT is Connected" /*+ " <---" + LanguageCollection[87].ToString()*/,
                            ThumbnailUrl = "https://raw.githubusercontent.com/kresmes/BDO-Boss-Timer-Discord-Bot-Yuri-Project-/master/Resources/Images/Connected.png",
                            Color        = Discord.Color.LightGrey,
                            //Url = publicbossUrl
                            Description = "All Notifications Will be Send to this channel"
                        };
                        await AlertChannel.SendMessageAsync("", false, Alert_Embed.Build());

                        Public_MainWindow.bossImageID = BossImage.Id;

                        //var embed = new EmbedBuilder
                        //{
                        //    Title = "Boss Name"
                        //};
                        //embed.AddField("Next Boss in:", "00:00:00", true);
                        //embed.AddField("Night In:", "00:00:00", true);
                        //embed.AddField("Imperial Reset:", "00:00:00", true)
                        //     .WithColor(Color.Blue)
                        //     .WithUrl("https://example.com")
                        //    .Build();
                        //var MainMessage = await channel.SendMessageAsync("", false, embed.Build());

                        string message = "";
                        Application.Current.Dispatcher.Invoke((Action)(() => {
                            string nb = "> ```cs" + Environment.NewLine + "> " + Public_MainWindow.CurrentBossTimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            string nti = "> ```cs" + Environment.NewLine + "> " + Public_MainWindow.NightInBdoTimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            string iri = "> ```cs" + Environment.NewLine + "> " + Public_MainWindow.IRTimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            string br = "> ```cs" + Environment.NewLine + "> " + Public_MainWindow.BRTimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            string itr = "> ```cs" + Environment.NewLine + "> " + Public_MainWindow.ITRITimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            if (Public_MainWindow.CurrentBossTimeLabel.Content.ToString().StartsWith("00:"))
                            {
                                nb = "> ```css" + Environment.NewLine + "> " + Public_MainWindow.CurrentBossTimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            }
                            if (Public_MainWindow.NightInBdoTimeLabel.Content.ToString().StartsWith("00:"))
                            {
                                nti = "> ```css" + Environment.NewLine + "> " + Public_MainWindow.NightInBdoTimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            }
                            if (Public_MainWindow.IRTimeLabel.Content.ToString().StartsWith("00:"))
                            {
                                iri = "> ```css" + Environment.NewLine + "> " + Public_MainWindow.IRTimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            }
                            if (Public_MainWindow.BRTimeLabel.Content.ToString().StartsWith("00:"))
                            {
                                br = "> ```css" + Environment.NewLine + "> " + Public_MainWindow.BRTimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            }
                            if (Public_MainWindow.ITRITimeLabel.Content.ToString().StartsWith("00:"))
                            {
                                itr = "> ```css" + Environment.NewLine + "> " + Public_MainWindow.ITRITimeLabel.Content.ToString() + Environment.NewLine + "> " + "```";
                            }


                            message = "> " + Public_MainWindow.CbossLabel.Content.ToString() + Environment.NewLine
                                      + nb + Environment.NewLine
                                      + "> " + Public_MainWindow.NILabel.Content.ToString() + Environment.NewLine
                                      + nti + Environment.NewLine
                                      + "> " + Public_MainWindow.IRILabel.Content.ToString() + Environment.NewLine
                                      + iri + Environment.NewLine
                                      + "> " + Public_MainWindow.BRILabel.Content.ToString() + Environment.NewLine
                                      + br + Environment.NewLine
                                      + "> " + Public_MainWindow.ITRILabel.Content.ToString() + Environment.NewLine
                                      + itr;
                        }));
                        Public_MainWindow.MainMessage = await channel.SendMessageAsync(message);

                        Public_MainWindow.MainMessageID = Public_MainWindow.MainMessage.Id;
                        Application.Current.Dispatcher.Invoke((Action)(() => {
                            if (Public_MainWindow.DiscordBotConnectionStatusLabel.Content.ToString() == Public_MainWindow.LanguageCollection[6].ToString())
                            {
                                Public_MainWindow.DiscordBotConnectionStatusLabel.Foreground = (Brush)bc.ConvertFrom("#FF669174");
                                Public_MainWindow.DiscordBotConnectionStatusLabel.Content = Public_MainWindow.LanguageCollection[8].ToString();//"Connected";
                            }
                        }));
                        bool DTT_isChecked = false;
                        Application.Current.Dispatcher.Invoke((Action)(() => { DTT_isChecked = Public_MainWindow.DisplayTimeTableSetting.IsChecked.Value; }));

                        if (DTT_isChecked)
                        {
                            var timetablemessage = await channel.SendFileAsync(System.IO.Directory.GetCurrentDirectory() + "/Resources/TimeTable.png", Public_MainWindow.MOTR.ToString().ToUpper() + Public_MainWindow.LanguageCollection[43].ToString());

                            Public_MainWindow.TimtableID = timetablemessage.Id;
                        }

                        if (Public_MainWindow.discord.ConnectionState == Discord.ConnectionState.Connected)
                        {
                            Application.Current.Dispatcher.Invoke((Action)(() => { MainWindow.SelfRollingStartUp(); }));
                        }
                        Public_MainWindow.isposting = 1;
                    }
                }
                catch (Exception s)
                {
                    if (s is Discord.Net.HttpException)
                    {
                        await Public_MainWindow.discord.StopAsync();

                        Application.Current.Dispatcher.Invoke((Action)(() => {
                            ErrorMessageBox emb = new ErrorMessageBox(Public_MainWindow.LanguageCollection[119].ToString(), Public_MainWindow.LanguageCollection[120].ToString(), Public_MainWindow.LanguageCollection[121].ToString(), Public_MainWindow.LanguageCollection[122].ToString());
                            emb.MB_typeOK(Public_MainWindow.LanguageCollection[108].ToString(), s.Message + Environment.NewLine + Environment.NewLine + Public_MainWindow.LanguageCollection[115].ToString(), Public_MainWindow);
                            emb.Show();
                            Public_MainWindow.IsEnabled = false;
                        }));
                    }
                    if (s is System.ArgumentOutOfRangeException)
                    {
                        await Public_MainWindow.discord.StopAsync();

                        Application.Current.Dispatcher.Invoke((Action)(() => {
                            ErrorMessageBox emb = new ErrorMessageBox(Public_MainWindow.LanguageCollection[119].ToString(), Public_MainWindow.LanguageCollection[120].ToString(), Public_MainWindow.LanguageCollection[121].ToString(), Public_MainWindow.LanguageCollection[122].ToString());
                            emb.MB_typeOK(Public_MainWindow.LanguageCollection[108].ToString(), s.Message + Environment.NewLine + Environment.NewLine + Public_MainWindow.LanguageCollection[116].ToString(), Public_MainWindow);
                            emb.Show();
                            Public_MainWindow.IsEnabled = false;
                        }));
                    }
                    if (s is System.NullReferenceException)
                    {
                        Application.Current.Dispatcher.Invoke((Action)(() => {
                            ErrorMessageBox emb = new ErrorMessageBox(Public_MainWindow.LanguageCollection[119].ToString(), Public_MainWindow.LanguageCollection[120].ToString(), Public_MainWindow.LanguageCollection[121].ToString(), Public_MainWindow.LanguageCollection[122].ToString());
                            emb.MB_typeOK(Public_MainWindow.LanguageCollection[113].ToString(), Public_MainWindow.LanguageCollection[124].ToString(), Public_MainWindow);
                            emb.Show();
                            Public_MainWindow.IsEnabled = false;
                        }));
                    }
                    var bc = new BrushConverter();
                    Application.Current.Dispatcher.Invoke((Action)(() => {
                        Public_MainWindow.DiscordBotConnectionStatusLabel.Foreground = (Brush)bc.ConvertFrom("#FFBB3D3D");
                        Public_MainWindow.DiscordBotConnectionStatusLabel.Content = Public_MainWindow.LanguageCollection[7].ToString();
                    }));

                    /*StartPosting();*/
                }
            }
            else
            {
                Application.Current.Dispatcher.Invoke((Action)(() => {
                    ErrorMessageBox emb = new ErrorMessageBox(Public_MainWindow.LanguageCollection[119].ToString(), Public_MainWindow.LanguageCollection[120].ToString(), Public_MainWindow.LanguageCollection[121].ToString(), Public_MainWindow.LanguageCollection[122].ToString());
                    emb.MB_typeOK(Public_MainWindow.LanguageCollection[113].ToString(), Public_MainWindow.LanguageCollection[124].ToString(), Public_MainWindow);
                    emb.Show();
                    Public_MainWindow.IsEnabled = false;
                }));
            }
        }