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();
                });
            }
        }
        public async Task UpdateHuntList()
        {
            //Roles with access
            List <string> roles = new List <string>();

            roles.Add(Setup.ApeChieftainRole);

            if (await Tools.RolesCheck(Context, roles, true, roles[0]))
            {
                SocketTextChannel channel = Context.Guild.GetTextChannel(Setup.HuntListChannelID);

                //Loaded data
                List <string> entries = new List <string>();
                //Load
                StringArray.Load(Setup.HuntListPath, ref entries);

                EmbedBuilder eb = new EmbedBuilder();
                await(channel as ISocketMessageChannel).SendFileAsync(Setup.HuntListBannerPicturePath);
                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);
                var huntListMessage = await(channel as ISocketMessageChannel).SendMessageAsync("", false, eb.Build());
                //Save message id so the client can always track the newly generated message incase it gets deleted
                ULongNormal.Save(Setup.HuntListDynamicIDPath, huntListMessage.Id);

                EmbedBuilder eb2 = new EmbedBuilder();
                eb2.Title = "⚠️ __**Kill and troll on sight**__🗡️";
                eb2.WithColor(Color.Gold);
                var infoMessage = await(channel as ISocketMessageChannel).SendMessageAsync("", false, eb2.Build());
                await infoMessage.AddReactionAsync(new Emoji("😄"));

                string text3 = "https://vimeo.com/284759578";
                await(channel as ISocketMessageChannel).SendMessageAsync(text3);
            }
            await Context.Message.DeleteAsync();
        }
Example #3
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();
            });
        }
        public async Task UpdateTimers()
        {
            //Roles with access
            List <string> roles = new List <string>();

            roles.Add(Setup.ApeChieftainRole);

            if (await Tools.RolesCheck(Context, roles, true, roles[0]))
            {
                SocketTextChannel channel = Context.Guild.GetTextChannel(Setup.TimerChannelID);

                //Points
                await channel.SendFileAsync(Setup.PointBannerPicturePath, "");

                EmbedBuilder pointsEB = new EmbedBuilder();
                pointsEB.WithColor(255, 255, 255);

                string gorillaTitle = Setup.GorillaEmoji + "House of Gorilla";
                string gorillaText  = "`0 Points`";
                pointsEB.AddField(Tools.CreateEmbedField(gorillaTitle, gorillaText, true));

                string monkeyTitle = Setup.MonkeyEmoji + "House of Monkey";
                string monkeyText  = "`0 Points`";
                pointsEB.AddField(Tools.CreateEmbedField(monkeyTitle, monkeyText, true));

                string baboonTitle = Setup.BaboonEmoji + "House of Baboon";
                string baboonText  = "`0 Points`";
                pointsEB.AddField(Tools.CreateEmbedField(baboonTitle, baboonText, true));
                var pointsMessage = await channel.SendMessageAsync("", false, pointsEB.Build());

                //Save message id so the client can always track the newly generated message incase it gets deleted
                ULongNormal.Save(Setup.PointsDynamicIDPath, pointsMessage.Id);

                //Events
                await channel.SendFileAsync(Setup.EventBannerPicturePath, "");

                EmbedBuilder EventsEB = new EmbedBuilder();
                EventsEB.WithColor(255, 248, 142);

                string waitEventTitle = "Events";
                string waitEventText  = "`None`";
                EventsEB.AddField(Tools.CreateEmbedField(waitEventTitle, waitEventText, true));

                string activeEventTitle = "Active events";
                string activeEventText  = "`None`";
                EventsEB.AddField(Tools.CreateEmbedField(activeEventTitle, activeEventText, true));

                EventsEB.WithThumbnailUrl(Setup.EventsTimerThumbnail);

                var eventMessage = await channel.SendMessageAsync("", false, EventsEB.Build());

                //Save message id so the client can always track the newly generated message incase it gets deleted
                ULongNormal.Save(Setup.EventsDynamicIDPath, eventMessage.Id);

                //Server
                await channel.SendFileAsync(Setup.ServerBannerPicturePath, "");

                EmbedBuilder ServerEB = new EmbedBuilder();
                ServerEB.Title = "Server information";
                string serverText = "`None`";
                ServerEB.WithDescription(serverText);
                ServerEB.WithColor(158, 97, 255);

                string generalEventsTitle = "General events";
                string generalEventsText  = "`None`";
                ServerEB.AddField(Tools.CreateEmbedField(generalEventsTitle, generalEventsText, true));

                string activeGeneralEventsTitle = "Active general events";
                string activeGeneralEventsText  = "`None`";
                ServerEB.AddField(Tools.CreateEmbedField(activeGeneralEventsTitle, activeGeneralEventsText, true));

                string specialEventsTitle = "Special events";
                string specialEventsText  = "`None`";
                ServerEB.AddField(Tools.CreateEmbedField(specialEventsTitle, specialEventsText, true));

                string activeSpecialEventsTitle = "Active special events";
                string activeSpecialEventsText  = "`None`";
                ServerEB.AddField(Tools.CreateEmbedField(activeSpecialEventsTitle, activeSpecialEventsText, true));

                ServerEB.WithThumbnailUrl(Setup.ServerTimerThumbnail);
                ServerEB.WithFooter("Timers maybe inaccurate due to no enough information, please send any information you know!");

                var serverMessage = await channel.SendMessageAsync("", false, ServerEB.Build());

                //Save message id so the client can always track the newly generated message incase it gets deleted
                ULongNormal.Save(Setup.ServerDynamicIDPath, serverMessage.Id);
            }
            await Context.Message.DeleteAsync();
        }