Пример #1
0
 private Contract(bool hasbeencouncilapproved, ulong staffchannelmsgid, ulong contractfilemessageid, ulong contractversionmessageid, ulong contractremarksmessageid, int contractversion, DateTime contractsenttime, string pendingContractFileURL, string pendingContractRemarks, int pullrequestid)
 {
     PendingContractFileURL = pendingContractFileURL;
     PendingContractRemarks = pendingContractRemarks;
     ContractSentTime       = contractsenttime;
     ContractVersion        = contractversion;
     HasBeenCouncilApproved = hasbeencouncilapproved;
     if (!HasBeenCouncilApproved)
     {
         StaffChannelMsg = staffchannelmsgid == 0 ? null : C_COUNCIL.GetMessageAsync(staffchannelmsgid).Result as IUserMessage;
     }
     else
     {
         StaffChannelMsg = staffchannelmsgid == 0 ? null :  C_MEMBER_CHANGES.GetMessageAsync(staffchannelmsgid).Result as IUserMessage;
     }
     ContractFileMessage    = contractfilemessageid == 0 ? null :  C_MEMBER_CONTRACT.GetMessageAsync(contractfilemessageid).Result as IUserMessage;
     ContractVersionMessage = contractversionmessageid == 0 ? null : C_MEMBER_CONTRACT.GetMessageAsync(contractversionmessageid).Result as IUserMessage;
     ContractRemarksMessage = contractremarksmessageid == 0 ? null : C_MEMBER_CONTRACT.GetMessageAsync(contractremarksmessageid).Result as IUserMessage;
     PullRequest            = pullrequestid > 0 ? DiscordBot.Services.GithubService.Client.GetPullRequest(DiscordBot.Services.GithubService.Client.GetRepository("CheAle14", "FourAcesContracts"), pullrequestid) : null;
 }
Пример #2
0
        // READY:
        public async Task Ready()
        {
            CasinoGuild         = _discord.GetGuild(402839443813302272);
            TestingGuild        = _discord.GetGuild(420240046428258304);
            TheGrandCodingGuild = _discord.GetGuild(365230804734967840);
            LoggingGuild        = _discord.GetGuild(508229402325286912);
            await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), ServiceProvider);     // Load commands and modules into the command service

            Services.GithubService.Client.RequestMade += GithubClient_RequestMade;

            foreach (var g in new SocketGuild[] { CasinoGuild, TestingGuild, TheGrandCodingGuild })
            {
                try
                {
                    string name      = g.Name.Replace("Casino", "");
                    var    usr       = g.GetUser(_discord.CurrentUser.Id);
                    bool   isSpecial = DateTime.Now.DayOfYear >= 355 && DateTime.Now.DayOfYear <= 359;
                    if (usr.Nickname != name || isSpecial)
                    {
                        await usr.ModifyAsync(x =>
                        {
                            if (isSpecial)
                            {
                                x.Nickname = $"{EM_RANDOM_CHRISTMAS} Merry Chistmas! {EM_RANDOM_CHRISTMAS}";
                            }
                            else
                            {
                                x.Nickname = name;
                            }
                        });
                    }
                } catch { }
            }

            await _discord.SetGameAsync($"{BOT_PREFIX}help - {DateTime.Now.ToShortTimeString()}");

            /*if(!BOT_DEBUG)
             * {
             *  await BotModule.ActuallyRemoveAllCommands(false, C_LOGS_OTHER_MISC);
             * }*/

            try
            {
                PastMessages = new PreviousMessages();
            }
            catch (Exception ex)
            {
                LogMessage bleh = new LogMessage(LogSeverity.Error, "PastMsgs", "", ex);
                LogMsg(bleh);
            }

            // Set up hour timer
            try
            {
                DateTime dueTime       = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, DateTime.Now.Hour + 1, 0, 0);
                TimeSpan timeRemaining = dueTime.Subtract(DateTime.Now);
                HourTimer.Interval = 50;
                HourTimer.Elapsed += HourElapsed;
                HourTimer.Enabled  = true;
            }
            catch (Exception ex)
            {
                LogMessage er = new LogMessage(LogSeverity.Error, "HourTimer", "", ex);
                LogMsg(er);
            }


            try
            {
                MasterList.MainMasterList.Run();
            }
            catch (Exception ex)
            {
                LogMsg("Error in Masterlist: " + ex.ToString(), LogSeverity.Error, "Masl");
                try
                {
                    await TheGrandCodingGuild.GetTextChannel(365233803217731584).SendMessageAsync($"Masterlist failed to start\nMasterlist will be unavailable.");
                } catch { }
                try
                {
                    var modl       = _commands.Modules.FirstOrDefault(x => x.Name == "Masterlist Commands");
                    var newDisable = new CommandDisabled("Masterlist failed to start", modl);
                    DisabledCommands.Add(newDisable);
                } catch { }
            }

            try
            {
                Casino.FourAcesCasino.Initialise();
            }
            catch (Exception ex)
            {
                LogMsg(ex.ToString(), LogSeverity.Critical, "StrCas");
                LogMsg("", LogSeverity.Critical, "StrCas");
                LogMsg("Unable to continue since the Casino failed to initialise", LogSeverity.Critical, "StrCas");
                try
                {
#if DEBUG
#else
                    await C_COUNCIL.SendMessageAsync($"Bot failed to start\nError message has been sent to Alex");
#endif
                    EmbedBuilder builder = new EmbedBuilder()
                    {
                        Title = "Erroed"
                    };
                    builder.AddField(x =>
                    {
                        x.Name     = "Message";
                        x.Value    = ex.Message;
                        x.IsInline = true;
                    });
                    builder.AddField(x =>
                    {
                        x.Name     = ex.InnerException == null ? "Source" : "Inner Exception";
                        x.Value    = ex.InnerException == null ? ex.Source : ex.InnerException.ToString();
                        x.IsInline = ex.InnerException == null ? true : false;
                    });
                    string errMsg = ex.ToString();
                    if (errMsg.Length > 1499 + " ...".Length)
                    {
                        errMsg = errMsg.Substring(0, 1499) + " ...";
                    }
                    builder.AddField(x =>
                    {
                        x.IsInline = false;
                        x.Name     = "Full Error";
                        x.Value    = "```" + errMsg.Replace("`", "'") + "```";
                    });
                    await U_BOB123.SendMessageAsync("Bot failure", false, builder.Build());

                    await C_LOGS_FAC_CHIP.SendMessageAsync("Unable to start bot due to Casino failure", false, builder.Build());
                }
                catch { }
                if (BOT_DEBUG)
                {
                    Console.ReadLine();
                }
                Environment.Exit(1);
            }
            var cp = new ChatProgramHandle();

            try
            {
                if (Program.Storage.LastDeletedBulkMessages != DateTime.Now.DayOfYear)
                {
                    Program.Storage.LastDeletedBulkMessages = DateTime.Now.DayOfYear;
                    await DeleteBulkMessages();
                }
            }
            catch (Exception ex)
            {
                LogMessage er = new LogMessage(LogSeverity.Critical, "NukeHWK", "", ex);
                LogMsg(er);
            }

            // Finished Loading all info
            LogMsg("Finished Ready() Function - Info Loaded.");
        }