public async Task ModifyHuntList(SocketCommandContext context, List <string> entries)
        {
            //Load dynamic channel id
            ulong loadedChannelID = 0;

            if (ULongNormal.Load(Setup.HuntListDynamicIDPath, ref loadedChannelID))
            {
                SocketTextChannel channel = context.Guild.GetTextChannel(Setup.HuntListChannelID);
                IMessage          message = await channel.GetMessageAsync(loadedChannelID);

                EmbedBuilder eb   = new EmbedBuilder();
                string       text = "";
                for (int i = 0; i < entries.Count; i++)
                {
                    text += "🔸 " + entries[i] + "\n";
                }
                if (entries.Count == 0)
                {
                    eb.WithDescription("No one is on the hunt list!");
                }
                else
                {
                    eb.WithDescription(text);
                }
                eb.WithColor(Color.Red);

                await(message as IUserMessage).ModifyAsync(msg =>
                {
                    msg.Embed = eb.Build();
                });
            }
        }
Beispiel #2
0
        static async Task UpdateTimers()
        {
            //Loaded data
            BinaryHouseNormal houseEntry         = new BinaryHouseNormal(0, 0, 0);
            BinaryEventArray  generalEventsEntry = new BinaryEventArray(new BinaryEvent[0]);
            BinaryEventArray  cbInfoEventsEntry  = new BinaryEventArray(new BinaryEvent[0]);
            BinaryEventArray  cbGenEventsEntry   = new BinaryEventArray(new BinaryEvent[0]);
            BinaryEventArray  cbSpecEventsEntry  = new BinaryEventArray(new BinaryEvent[0]);
            ulong             pointsDynamicID    = 0;
            ulong             eventsDynamicID    = 0;
            ulong             serverDynamicID    = 0;

            //Load
            HouseNormal.Load(Setup.HousePath, ref houseEntry);
            EventArray.Load(Setup.GeneralEventsPath, ref generalEventsEntry);
            EventArray.Load(Setup.CBInfoEventsPath, ref cbInfoEventsEntry);
            EventArray.Load(Setup.CBGenEventsPath, ref cbGenEventsEntry);
            EventArray.Load(Setup.CBSpecEventsPath, ref cbSpecEventsEntry);
            ULongNormal.Load(Setup.PointsDynamicIDPath, ref pointsDynamicID);
            ULongNormal.Load(Setup.EventsDynamicIDPath, ref eventsDynamicID);
            ULongNormal.Load(Setup.ServerDynamicIDPath, ref serverDynamicID);

            IMessage pointsMessage = await Setup.Client.GetGuild(Setup.ApeGangGuildID).GetTextChannel(Setup.TimerChannelID).GetMessageAsync(pointsDynamicID);

            IMessage eventsMessage = await Setup.Client.GetGuild(Setup.ApeGangGuildID).GetTextChannel(Setup.TimerChannelID).GetMessageAsync(eventsDynamicID);

            IMessage serverMessage = await Setup.Client.GetGuild(Setup.ApeGangGuildID).GetTextChannel(Setup.TimerChannelID).GetMessageAsync(serverDynamicID);

            List <IEmbed> pointsEmbeds = pointsMessage.Embeds.ToList();
            List <IEmbed> eventsEmbeds = eventsMessage.Embeds.ToList();
            List <IEmbed> serverEmbeds = serverMessage.Embeds.ToList();

            EmbedBuilder pointsEB = pointsEmbeds[0].ToEmbedBuilder();
            EmbedBuilder eventsEB = eventsEmbeds[0].ToEmbedBuilder();
            EmbedBuilder serverEB = serverEmbeds[0].ToEmbedBuilder();

            //points
            for (int i = 0; i < pointsEB.Fields.Count; i++)
            {
                if (pointsEB.Fields[i].Name == Setup.GorillaEmoji + "House of Gorilla")
                {
                    pointsEB.Fields[i].WithValue("`" + houseEntry.GorillaPoints + " Points`");
                }
                else if (pointsEB.Fields[i].Name == Setup.MonkeyEmoji + "House of Monkey")
                {
                    pointsEB.Fields[i].WithValue("`" + houseEntry.MonkeyPoints + " Points`");
                }
                else if (pointsEB.Fields[i].Name == Setup.BaboonEmoji + "House of Baboon")
                {
                    pointsEB.Fields[i].WithValue("`" + houseEntry.BaboonPoints + " Points`");
                }
            }

            //events
            //Splits the events into two category
            bool          saveEventsEntry = false;
            List <string> eventsInactive  = new List <string>();
            List <string> eventsActive    = new List <string>();

            TimeCalculation(ref generalEventsEntry, ref eventsInactive, ref eventsActive, ref saveEventsEntry);
            //Save
            if (saveEventsEntry)
            {
                EventArray.Save(Setup.GeneralEventsPath, generalEventsEntry);
            }

            for (int i = 0; i < eventsEB.Fields.Count; i++)
            {
                string fieldText = "";
                if (eventsEB.Fields[i].Name == "Events")
                {
                    if (eventsInactive.Count == 0)
                    {
                        fieldText = "`None`";
                    }
                    for (int j = 0; j < eventsInactive.Count; j++)
                    {
                        fieldText += "`" + eventsInactive[j] + "`" + "\n";
                    }
                    eventsEB.Fields[i].WithValue(fieldText);
                }
                else if (eventsEB.Fields[i].Name == "Active events")
                {
                    if (eventsActive.Count == 0)
                    {
                        fieldText = "`None`";
                    }
                    for (int j = 0; j < eventsActive.Count; j++)
                    {
                        fieldText += "`" + eventsActive[j] + "`" + "\n";
                    }
                    eventsEB.Fields[i].WithValue(fieldText);
                }
            }

            //server
            bool          saveCBInfoEntry = false;
            bool          saveCBGenEntry  = false;
            bool          saveCBSpecEntry = false;
            List <string> CBInfoInactive  = new List <string>();
            List <string> CBInfoActive    = new List <string>();
            List <string> CBGenInactive   = new List <string>();
            List <string> CBGenActive     = new List <string>();
            List <string> CBSpecInactive  = new List <string>();
            List <string> CBSpecActive    = new List <string>();

            TimeCalculation(ref cbInfoEventsEntry, ref CBInfoInactive, ref CBInfoActive, ref saveCBInfoEntry);
            TimeCalculation(ref cbGenEventsEntry, ref CBGenInactive, ref CBGenActive, ref saveCBGenEntry);
            TimeCalculation(ref cbSpecEventsEntry, ref CBSpecInactive, ref CBSpecActive, ref saveCBSpecEntry);
            //Save
            if (saveCBInfoEntry)
            {
                EventArray.Save(Setup.CBInfoEventsPath, cbInfoEventsEntry);
            }
            if (saveCBGenEntry)
            {
                EventArray.Save(Setup.CBGenEventsPath, cbGenEventsEntry);
            }
            if (saveCBSpecEntry)
            {
                EventArray.Save(Setup.CBSpecEventsPath, cbSpecEventsEntry);
            }

            string serverText = "`Server time: " + DateTimeOffset.Now.ToOffset(Setup.CurrentTimeZone.BaseUtcOffset).ToString("HH:mm:ss (M/dd/yyyy)") + "`" + "\n";

            for (int j = 0; j < CBInfoInactive.Count; j++)
            {
                serverText += "`" + CBInfoInactive[j] + "`" + "\n";
            }
            for (int j = 0; j < CBInfoActive.Count; j++)
            {
                serverText += "`" + CBInfoActive[j] + "`" + "\n";
            }
            serverEB.WithDescription(serverText);

            for (int i = 0; i < serverEB.Fields.Count; i++)
            {
                string fieldText = "";
                if (serverEB.Fields[i].Name == "General events")
                {
                    if (CBGenInactive.Count == 0)
                    {
                        fieldText = "`None`";
                    }
                    for (int j = 0; j < CBGenInactive.Count; j++)
                    {
                        fieldText += "`" + CBGenInactive[j] + "`" + "\n";
                    }
                    serverEB.Fields[i].WithValue(fieldText);
                }
                else if (serverEB.Fields[i].Name == "Active general events")
                {
                    if (CBGenActive.Count == 0)
                    {
                        fieldText = "`None`";
                    }
                    for (int j = 0; j < CBGenActive.Count; j++)
                    {
                        fieldText += "`" + CBGenActive[j] + "`" + "\n";
                    }
                    serverEB.Fields[i].WithValue(fieldText);
                }
                else if (serverEB.Fields[i].Name == "Special events")
                {
                    if (CBSpecInactive.Count == 0)
                    {
                        fieldText = "`None`";
                    }
                    for (int j = 0; j < CBSpecInactive.Count; j++)
                    {
                        fieldText += "`" + CBSpecInactive[j] + "`" + "\n";
                    }
                    serverEB.Fields[i].WithValue(fieldText);
                }
                else if (serverEB.Fields[i].Name == "Active special events")
                {
                    if (CBSpecActive.Count == 0)
                    {
                        fieldText = "`None`";
                    }
                    for (int j = 0; j < CBSpecActive.Count; j++)
                    {
                        fieldText += "`" + CBSpecActive[j] + "`" + "\n";
                    }
                    serverEB.Fields[i].WithValue(fieldText);
                }
            }

            await(pointsMessage as IUserMessage).ModifyAsync(msg =>
            {
                msg.Embed = pointsEB.Build();
            });

            await(eventsMessage as IUserMessage).ModifyAsync(msg =>
            {
                msg.Embed = eventsEB.Build();
            });

            await(serverMessage as IUserMessage).ModifyAsync(msg =>
            {
                msg.Embed = serverEB.Build();
            });
        }