public async Task ShowGuilds()
        {
            System.Collections.Generic.IReadOnlyCollection <IGuild> Guilds = await bot.Client.GetGuildsAsync();

            StringBuilder sb = new StringBuilder()
                               .AppendLine("Current Guilds And Member Count Using WarBot")
                               .AppendLine("```");

            foreach (SocketGuild g in Guilds.OfType <SocketGuild>().OrderByDescending(o => o.MemberCount))
            {
                sb.AppendLine($"{g.MemberCount.ToString().PadRight(4, ' ')}\t{g.Name}");

                //Discord's api has a max length allowed. Once we get near this length, we need to send the message and start formatting a new message.
                if (sb.Length > 1900)
                {
                    ///Close the "Code" block.
                    sb.AppendLine("```");

                    //Send the current string buffer.
                    await ReplyAsync(sb.ToString());

                    //Clear the current buffer, and re-open a new "code" block.
                    sb.Clear()
                    .AppendLine("```");
                }
            }
            sb.AppendLine("```");

            // ReplyAsync is a method on ModuleBase
            await ReplyAsync(sb.ToString());
        }
Beispiel #2
0
        public async Task InsertIfNotExistAsync_ShouldInsertAndReturnAllEntitiest_WhenThereAreNoExistingEntities(DbProvider provider, TestConfiguration testConfiguration = TestConfiguration.Default)
        {
            TestEntity[] expectedEntitiesToBeInserted = new[]
            {
                new TestEntity {
                    Id = "1", IntTestValue = 111, StringTestValue = "a", BoolTestValue = false, DateTimeTestValue = DateTime.UtcNow, LongTestValue = 15451455587546
                },
                new TestEntity {
                    Id = "3", IntTestValue = 333, StringTestValue = "a", BoolTestValue = false, DateTimeTestValue = new DateTime(15645325746541), LongTestValue = 7451524264
                },
            };

            using TestDbContext context = await ContextFactory.GetDbContextAsync(provider, testConfiguration : testConfiguration);

            // Validate that the DB doesn't have any entities
            (await context.TestEntities.CountAsync()).Should().Be(0);

            // Invoke the method and check that the result is the expected entities
            System.Collections.Generic.IReadOnlyCollection <TestEntity> actualInsertedEntities = await context.InsertIfNotExistAsync(context.TestEntities, expectedEntitiesToBeInserted);

            actualInsertedEntities.Should().BeEquivalentTo(expectedEntitiesToBeInserted);

            // Then check that the actual DB contains the expected entities
            TestEntity[] actualEntities = await context.TestEntities.ToArrayAsync();

            actualEntities.Should().BeEquivalentTo(expectedEntitiesToBeInserted);
        }
Beispiel #3
0
        private async Task _client_MessagesBulkDeleted(System.Collections.Generic.IReadOnlyCollection <Cacheable <IMessage, ulong> > messages, ISocketMessageChannel channel)
        {
            ulong         guildID    = ((SocketTextChannel)channel).Guild.Id;
            StringBuilder fieldValue = new StringBuilder();

            foreach (Cacheable <IMessage, ulong> cached in messages)
            {
                fieldValue.Append(cached.Id + ", ");
            }

            var origField = new EmbedFieldBuilder()
                            .WithName(messages.Count + " Messages Deleted")
                            .WithValue(fieldValue.ToString());
            var footer = new EmbedFooterBuilder()
                         .WithIconUrl(_client.CurrentUser.GetAvatarUrl())
                         .WithText("ArbitiesLog");
            var embed = new EmbedBuilder()
                        .AddField(origField)
                        .WithFooter(footer)
                        .WithColor(Color.Red)
                        .Build();
            GuildData guildData = await GuildManager.GetGuildData(guildID);

            await((SocketTextChannel)_client.GetChannel(guildData.LogChannel)).SendMessageAsync(embed: embed);
        }
Beispiel #4
0
        private void DisplayResults(System.Collections.Generic.IReadOnlyCollection <post> documents)
        {
            this.panelResults.Controls.Clear();

            var top    = 30;
            var shaded = false;

            foreach (var document in documents)
            {
                var lbl = new Label
                {
                    Location = new Point(16, top),
                    Size     = new Size(panelResults.Width - 32, 30),
                    TabIndex = 0,
                    Text     = Summary(document.title, document.body),
                    Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top
                };
                if (shaded)
                {
                    lbl.BackColor = Color.LightGray;
                }
                this.panelResults.Controls.Add(lbl);
                shaded = !shaded;
                top   += 40;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceFailureActionsInfo"/> class.
        /// </summary>
        internal ServiceFailureActionsInfo(System.TimeSpan resetPeriod, string rebootMessage, string restartCommand
                                           , System.Collections.Generic.IReadOnlyCollection <ScAction> actions)
        {
            dwResetPeriod = resetPeriod == System.TimeSpan.MaxValue ? uint.MaxValue : (uint)System.Math.Round(resetPeriod.TotalSeconds);
            lpRebootMsg   = rebootMessage;
            lpCommand     = restartCommand;
            cActions      = actions?.Count ?? 0;

            if (null != actions)
            {
                lpsaActions = System.Runtime.InteropServices.Marshal.AllocHGlobal(
                    System.Runtime.InteropServices.Marshal.SizeOf <ScAction>() * cActions
                    );

                if (lpsaActions == System.IntPtr.Zero)
                {
                    throw new System.Exception(
                              string.Format("Unable to allocate memory for service action, error was: 0x{0:X}"
                                            , System.Runtime.InteropServices.Marshal.GetLastWin32Error()));
                }

                System.IntPtr nextAction = lpsaActions;

                foreach (ScAction action in actions)
                {
                    System.Runtime.InteropServices.Marshal.StructureToPtr(action, nextAction, fDeleteOld: false);
                    nextAction = (System.IntPtr)(nextAction.ToInt64() + System.Runtime.InteropServices.Marshal.SizeOf <ScAction>());
                }
            }
            else
            {
                lpsaActions = System.IntPtr.Zero;
            }
        }
Beispiel #6
0
        /// <inheritdoc/>
        public async Task Process(IConnection connection, SmtpCommand command)
        {
            if (connection.CurrentMessage != null)
            {
                await connection.WriteResponse(new SmtpResponse(
                                                   StandardSmtpResponseCode.BadSequenceOfCommands,
                                                   "You already told me who the message was from")).ConfigureAwait(false);

                return;
            }

            if (command.ArgumentsText.Length == 0)
            {
                await connection.WriteResponse(
                    new SmtpResponse(
                        StandardSmtpResponseCode.SyntaxErrorInCommandArguments,
                        "Must specify from address or <>")).ConfigureAwait(false);

                return;
            }

            ArgumentsParser argumentsParser = new ArgumentsParser(command.ArgumentsText);

            System.Collections.Generic.IReadOnlyCollection <string> arguments = argumentsParser.Arguments;

            string from = arguments.First();

            if (from.StartsWith("<", StringComparison.OrdinalIgnoreCase))
            {
                from = from.Remove(0, 1);
            }

            if (from.EndsWith(">", StringComparison.OrdinalIgnoreCase))
            {
                from = from.Remove(from.Length - 1, 1);
            }

            await connection.Server.Behaviour.OnMessageStart(connection, from).ConfigureAwait(false);

            await connection.NewMessage().ConfigureAwait(false);

            connection.CurrentMessage.ReceivedDate = this.currentDateTimeProvider.GetCurrentDateTime();
            connection.CurrentMessage.From         = from;

            try
            {
                await this.ParameterProcessorMap.Process(connection, arguments.Skip(1).ToArray(), true).ConfigureAwait(false);

                await connection.WriteResponse(new SmtpResponse(StandardSmtpResponseCode.OK, "New message started")).ConfigureAwait(false);
            }
            catch
            {
                await connection.AbortMessage().ConfigureAwait(false);

                throw;
            }
        }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceFailureActions" /> class.
 /// </summary>
 /// <param name="resetPeriod">The reset period in seconds after which previous failures are cleared.</param>
 /// <param name="rebootMessage">The reboot message used in case a reboot failure action is contaiend in <paramref name="actions"/>.</param>
 /// <param name="restartCommand">The command run in case a "run command" failure action is contained in <paramref name="actions"/>.</param>
 /// <param name="actions">The failure actions.</param>
 public ServiceFailureActions(System.TimeSpan resetPeriod
                              , string rebootMessage
                              , string restartCommand
                              , System.Collections.Generic.IReadOnlyCollection <ScAction> actions)
 {
     ResetPeriod    = resetPeriod;
     RebootMessage  = rebootMessage;
     RestartCommand = restartCommand;
     Actions        = actions;
 }
Beispiel #8
0
        private DataMessage(SerializationInfo info, StreamingContext context)
        {
            if (info is null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            Message = info.GetString(nameof(Message));
            Data    = info.GetValue <byte[]>(nameof(Data));
        }
        public void GetCalendarNamesSuccessfully()
        {
            //arrange
            JobStore.StoreCalendar("cal1", CreateCalendar(), false, false);
            JobStore.StoreCalendar("cal2", CreateCalendar(), false, false);

            //act
            System.Collections.Generic.IReadOnlyCollection <string> result = JobStore.GetCalendarNames().Result;

            //assert
            Assert.IsTrue(result.Count == 2);
        }
        public async Task AddMessage()
        {
            IEditableSession session = this.GetSession();
            Mock <IMessage>  message = new Mock <IMessage>();

            session.AddMessage(message.Object);

            System.Collections.Generic.IReadOnlyCollection <IMessage> messages = await session.GetMessages();

            Assert.Single(messages);
            Assert.Same(message.Object, messages.First());
        }
Beispiel #11
0
        public async Task InsertIfNotExistAsync_ShouldNotInsertEntities_WhenNoEntitiesGiven(DbProvider provider, TestConfiguration testConfiguration = TestConfiguration.Default)
        {
            using TestDbContext context = await ContextFactory.GetDbContextAsync(provider, testConfiguration : testConfiguration);

            // Validate that the DB doesn't have any entities
            (await context.TestEntities.CountAsync()).Should().Be(0);

            // Invoke the method and check that the result is the expected entities
            System.Collections.Generic.IReadOnlyCollection <TestEntity> actualInsertedEntities = await context.InsertIfNotExistAsync(context.TestEntities, new TestEntity[0]);

            actualInsertedEntities.Should().BeEmpty();

            // Then check that the actual DB contains no entities
            (await context.TestEntities.CountAsync()).Should().Be(0);
        }
Beispiel #12
0
        public async Task GetGuildMemberList(CommandContext commandContext)
        {
            DiscordGuild guild = commandContext.Member.Guild;

            System.Collections.Generic.IReadOnlyCollection <DiscordMember> readOnlyCollections = await guild.GetAllMembersAsync();

            await commandContext.Channel.SendMessageAsync("Guild " + guild.Name + " members count " + readOnlyCollections.Count.ToString());

            string memberList = string.Empty;

            foreach (DiscordMember member in readOnlyCollections)
            {
                memberList += member.DisplayName + ",";
            }
            await commandContext.Channel.SendMessageAsync(memberList.TrimEnd(','));
        }
Beispiel #13
0
        private static void DisplayCustomerList(System.Collections.Generic.IReadOnlyCollection <Customer> customerList)
        {
            Console.WriteLine("=======================");
            int count = 1;

            foreach (var customer in customerList)
            {
                Console.WriteLine($"Item #{count}");
                Console.WriteLine($"Customer Id: {customer.Id}");
                Console.WriteLine($"Given Name: {customer.GivenName}");
                Console.WriteLine($"Family Name: {customer.FamilyName}");
                Console.WriteLine("---");
                count++;
            }
            Console.WriteLine("=======================");
        }
Beispiel #14
0
        public async Task Comic()
        {
            System.Collections.Generic.IReadOnlyCollection <Attachment> attachments = Context.Message.Attachments;
            if (attachments.Count == 0)
            {
                await Send_img_plsAsync("You didnt attach a image").ConfigureAwait(false);

                return;
            }
            else if (attachments.Count > 1)
            {
                await Send_img_plsAsync("You attached more than one image").ConfigureAwait(false);

                return;
            }
            await Context.Channel.SendFileAsync(Filter(new WebClient().DownloadData(attachments.ElementAt(0).Url), MatrixFilters.Comic), "silverbotimage.png", "There ya go a image with the comic filter");
        }
Beispiel #15
0
        public async Task ReceivedApiCalls_GetsAllRecordedApiCalls()
        {
            ApiBuilder apiBuilder = new ApiBuilder(Substitute.For <ISimulation>())
                                    .AddHandler("GET /api/v2/books", _ => throw new Exception());
            var apiSimulator = new ApiSimulator(apiBuilder);

            try
            {
                await apiSimulator.StartAsync();

                var port = apiSimulator.Port;

                using var httpClient = new HttpClient();
                var task1 = Task.Run(async() =>
                {
                    var request = new HttpRequestMessage(HttpMethod.Get, $"http://localhost:{port}/api/v2/books");
                    await httpClient.SendAsync(request);
                });
                var task2 = Task.Run(async() =>
                {
                    var request = new HttpRequestMessage(HttpMethod.Patch, $"http://localhost:{port}/api/v2/books/32")
                    {
                        Content = new StringContent("{\"title\":\"abc\"}", Encoding.UTF8, "application/json")
                    };
                    await httpClient.SendAsync(request);
                });
                await Task.WhenAll(task1, task2);
            }
            finally
            {
                await apiSimulator.StopAsync();
            }

            System.Collections.Generic.IReadOnlyCollection <ApiCall> apiCalls = apiSimulator.ReceivedApiCalls;
            ApiCall getCall = apiCalls.FirstOrDefault(call => call.Action == "GET /api/v2/books");

            apiCalls.ShouldSatisfyAllConditions(
                () => getCall.ShouldNotBeNull(),
                () => getCall.Exception.ShouldNotBeNull(),
                () => apiCalls.Count.ShouldBe(2),
                () => apiCalls
                .Single(call => call.Action == "PATCH /api/v2/books/32")
                .ShouldNotBeNull()
                );
        }
Beispiel #16
0
        public async Task Jpegize()
        {
            System.Collections.Generic.IReadOnlyCollection <Attachment> attachments = Context.Message.Attachments;
            if (attachments.Count == 0)
            {
                await Send_img_plsAsync("You didnt attach a image");

                return;
            }
            else if (attachments.Count > 1)
            {
                await Send_img_plsAsync("You attached more than one image");

                return;
            }
            using WebClient myWebClient  = new WebClient();
            using MemoryStream outStream = Make_jpegnised(myWebClient.DownloadData(attachments.ElementAt(0).Url));
            await Context.Channel.SendFileAsync(outStream, "silverbotimage.jpeg", "There ya go a jpegnized image");
        }
Beispiel #17
0
        public async Task GetAllGuildMemberList(CommandContext commandContext)
        {
            System.Collections.Generic.IReadOnlyDictionary <ulong, DiscordGuild> guilds = commandContext.Client.Guilds;
            await commandContext.Channel.SendMessageAsync("Guild count " + guilds.Count.ToString());

            foreach (System.Collections.Generic.KeyValuePair <ulong, DiscordGuild> guild in guilds)
            {
                System.Collections.Generic.IReadOnlyCollection <DiscordMember> readOnlyCollections = await guild.Value.GetAllMembersAsync();

                await commandContext.Channel.SendMessageAsync("Guild " + guild.Value.Name + " members count " + readOnlyCollections.Count.ToString());

                string memberList = string.Empty;
                foreach (DiscordMember member in readOnlyCollections)
                {
                    memberList += member.DisplayName + ",";
                }
                await commandContext.Channel.SendMessageAsync(memberList.TrimEnd(','));
            }
        }
Beispiel #18
0
        public async Task InsertIfNotExistAsync_ShouldInsertAndReturnEntitiesWhichNotExist_WhenThereAreExistingEntities(DbProvider provider, TestConfiguration testConfiguration = TestConfiguration.Default)
        {
            TestEntity[] existingEntities = new[]
            {
                new TestEntity {
                    Id = "2", IntTestValue = 222, StringTestValue = "a"
                },
                new TestEntity {
                    Id = "4", IntTestValue = 444, StringTestValue = "a"
                },
                new TestEntity {
                    Id = "5", IntTestValue = 333, StringTestValue = "a"
                },
            };

            TestEntity[] expectedEntitiesToBeInserted = new[]
            {
                new TestEntity {
                    Id = "1", IntTestValue = 111, StringTestValue = "a", BoolTestValue = false, DateTimeTestValue = DateTime.UtcNow, LongTestValue = 15451455587546
                },
                new TestEntity {
                    Id = "3", IntTestValue = 333, StringTestValue = "a", BoolTestValue = false, DateTimeTestValue = new DateTime(15645325746541), LongTestValue = 7451524264
                },
            };

            // First, add the entities which should exist before we perform our test.
            using TestDbContext context = await ContextFactory.GetDbContextAsync(provider, testConfiguration : testConfiguration);

            context.TestEntities.AddRange(existingEntities);
            await context.SaveChangesAsync();

            // Then try to insert some entities which already exists + the expectedEntitiesToBeInserted
            TestEntity[] entitiesToInsert = existingEntities.Take(2).Concat(expectedEntitiesToBeInserted).ToArray();
            System.Collections.Generic.IReadOnlyCollection <TestEntity> actualInsertedEntities = await context.InsertIfNotExistAsync(context.TestEntities, entitiesToInsert);

            // Check that the returned result is only expectedEntitiesToBeInserted, i.e. that the entities which already exist haven't been "inserted again"
            actualInsertedEntities.Should().BeEquivalentTo(expectedEntitiesToBeInserted);

            // Then check that the actual DB contains the expected entities
            TestEntity[] actualEntities = await context.TestEntities.ToArrayAsync();

            actualEntities.Should().BeEquivalentTo(existingEntities.Concat(expectedEntitiesToBeInserted));
        }
        public async Task ForceRun <T, D>(string key, string group)
            where T : IBlackPearlJob <D>
            where D : class, new()
        {
            if (scheduler == null)
            {
                return;
            }

            var  jobKey    = new JobKey(key, group);
            bool jobExists = await scheduler.CheckExists(jobKey);

            if (!jobExists)
            {
                return;
            }

            System.Collections.Generic.IReadOnlyCollection <ITrigger> trigger = await scheduler.GetTriggersOfJob(jobKey);

            await scheduler.TriggerJob(jobKey, trigger?.FirstOrDefault()?.JobDataMap);
        }
Beispiel #20
0
        public async Task InsertIfNotExistAsync_ShouldInsertDbNull_WhenObjectValueIsNull()
        {
            TestEntity[] expectedEntitiesToBeInserted = new[]
            {
                new TestEntity {
                    Id = "1", StringTestValue = null, IntTestValue = 111, BoolTestValue = false, DateTimeTestValue = DateTime.UtcNow, LongTestValue = 15451455587546
                },
            };

            using TestDbContext context = await ContextFactory.GetDbContextAsync(DbProvider.SqlServer);

            // Validate that the DB doesn't have any entities
            (await context.TestEntities.CountAsync()).Should().Be(0);

            // Invoke the method and check that the result is the expected entities
            System.Collections.Generic.IReadOnlyCollection <TestEntity> actualInsertedEntities = await context.InsertIfNotExistAsync(context.TestEntities, expectedEntitiesToBeInserted);

            actualInsertedEntities.Should().BeEquivalentTo(expectedEntitiesToBeInserted);

            // Then check that the actual DB contains the expected entities
            TestEntity[] actualEntities = await context.TestEntities.ToArrayAsync();

            actualEntities.Should().BeEquivalentTo(expectedEntitiesToBeInserted);
        }
 private Task Client_MessagesBulkDeleted(System.Collections.Generic.IReadOnlyCollection <Cacheable <IMessage, ulong> > arg1, ISocketMessageChannel arg2)
 {
     return(Task.CompletedTask);
 }
Beispiel #22
0
 public DataMessage(string message, byte[] data)
 {
     Message = message;
     Data    = data;
 }
Beispiel #23
0
 public static Azure.Identity.DeviceCodeInfo DeviceCodeInfo(string userCode, string deviceCode, System.Uri verificationUri, System.DateTimeOffset expiresOn, string message, string clientId, System.Collections.Generic.IReadOnlyCollection <string> scopes)
 {
     throw null;
 }
 void ITextViewConnectionListener.SubjectBuffersDisconnected(ITextView textView, ConnectionReason reason, System.Collections.Generic.IReadOnlyCollection <ITextBuffer> subjectBuffers)
 {
     SubjectBuffersDisconnected((IWpfTextView)textView, reason, new System.Collections.ObjectModel.Collection <ITextBuffer>(subjectBuffers.ToArray()));
 }
Beispiel #25
0
 public CommandResult(System.Collections.Generic.IReadOnlyCollection <Notification> notifications, object content)
 {
     Success = notifications.Count == 0;
     Message = string.Join(",", notifications.Select(item => item.Message).ToArray());
     Content = content;
 }
        //Update user session when bot comes online
        private async Task StartUserSession()
        {
            await Task.Run(() =>
            {
                Console.WriteLine("Initiate Boot Sequence");
                //Guild list in IReadOnlyCollection<SocketGuild>
                pGuildList = client.Guilds;

                //String for query (unsafe)
                StringBuilder sbsession  = new StringBuilder();
                StringBuilder sbactivity = new StringBuilder();

                Console.WriteLine("Getting users from database");

                //Read from table discorduser
                var dbUserList = Database.CheckExistingUser();

                //Compare with list from guild(s?)

                //Add new user if not found

                //String for session query string
                sbsession.Append("INSERT INTO usersession  (session_start , session_end , user_id , user_ign , force_end , guild_id ) VALUES ");

                //String for activity query string
                sbactivity.Append("SET ANSI_WARNINGS OFF;");

                //check list of guilds the bot is
                foreach (SocketGuild guild in pGuildList)
                {
                    Console.WriteLine(string.Format("Guild Name: {0}, Guild Id: {1}", guild.Name, guild.Id));
                    //Gets list of users in guild which are online

                    var userList = guild.Users;

                    Console.WriteLine("Updating database entry, session and activity for users");
                    foreach (SocketUser user in userList)
                    {
                        //Compare current user with database, if not found then update user database
                        if (!dbUserList.Contains(user.Id.ToString()))
                        {
                            Database.EnterUser(user);
                        }

                        if (user.Status.ToString() != "Offline")
                        {
                            //Generate new user session
                            sbsession.Append(string.Format("('{0}', '{1}','{2}','{3}','{4}','{5}'),",
                                                           DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "", user.Id, user.Username, "", guild.Id));

                            //Generate new user activity
                            sbactivity.Append(string.Format("INSERT INTO useractivity (user_ign ,session_id , status_before , status_after , game_id , timestamp) SELECT '{0}', session_id, '{1}', '{2}', '{3}', '{4}' FROM usersession WHERE user_id = '{5}' AND session_end = '';",
                                                            user.Username, "Console Inactive", user.Status.ToString(), user.Game.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), user.Id));
                        }
                    }
                }
                //Remove comma from sbsession string and add semi colon behind
                sbsession.Remove(sbsession.Length - 1, 1);
                sbsession.Append(";");

                Console.WriteLine(string.Format("Executing Command StartUserSession"));

                //instantiate database

                Database database = new Database("discord");

                Database.QueryAnnounce(database, sbsession, "StartUserSessions");

                Database database1 = new Database("discord");

                Database.QueryAnnounce(database1, sbactivity, "StartUserActivities");
            });
        }
Beispiel #27
0
 public async Task Testget()
 {
     try
     {
         System.Collections.Generic.IReadOnlyCollection <Discord.Rest.RestGuildTemplate> Temps = await Context.Guild.GetTemplatesAsync();
         await ReplyAsync(Temps.Count.ToString());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Beispiel #28
0
 protected override bool IsProjectConfigurationVersionOutOfDate(System.Collections.Generic.IReadOnlyCollection <PackageRestoreConfiguredInput>?configuredInputs)
 {
     return(false);
 }
Beispiel #29
0
        internal static string Resolve(IMessage msg, int startIndex, TagHandling userHandling, TagHandling channelHandling, TagHandling roleHandling, TagHandling everyoneHandling, TagHandling emojiHandling)
        {
            StringBuilder text = new StringBuilder(msg.Content.Substring(startIndex));

            System.Collections.Generic.IReadOnlyCollection <ITag> tags = msg.Tags;
            int indexOffset = -startIndex;

            foreach (ITag tag in tags)
            {
                if (tag.Index < startIndex)
                {
                    continue;
                }

                string newText = "";
                switch (tag.Type)
                {
                case TagType.UserMention:
                    if (userHandling == TagHandling.Ignore)
                    {
                        continue;
                    }
                    newText = ResolveUserMention(tag, userHandling);
                    break;

                case TagType.ChannelMention:
                    if (channelHandling == TagHandling.Ignore)
                    {
                        continue;
                    }
                    newText = ResolveChannelMention(tag, channelHandling);
                    break;

                case TagType.RoleMention:
                    if (roleHandling == TagHandling.Ignore)
                    {
                        continue;
                    }
                    newText = ResolveRoleMention(tag, roleHandling);
                    break;

                case TagType.EveryoneMention:
                    if (everyoneHandling == TagHandling.Ignore)
                    {
                        continue;
                    }
                    newText = ResolveEveryoneMention(tag, everyoneHandling);
                    break;

                case TagType.HereMention:
                    if (everyoneHandling == TagHandling.Ignore)
                    {
                        continue;
                    }
                    newText = ResolveHereMention(tag, everyoneHandling);
                    break;

                case TagType.Emoji:
                    if (emojiHandling == TagHandling.Ignore)
                    {
                        continue;
                    }
                    newText = ResolveEmoji(tag, emojiHandling);
                    break;
                }
                text.Remove(tag.Index + indexOffset, tag.Length);
                text.Insert(tag.Index + indexOffset, newText);
                indexOffset += newText.Length - tag.Length;
            }
            return(text.ToString());
        }
        public DiscordEmbed EmbedSteamResult(SteamCommunityProfileModel model, PlayerSummaryModel summary)
        {
            if (this.IsDisabled())
            {
                return(null);
            }

            var em = new DiscordEmbedBuilder {
                Title        = summary.Nickname,
                Description  = Regex.Replace(model.Summary, "<[^>]*>", string.Empty),
                ThumbnailUrl = model.AvatarFull.ToString(),
                Color        = DiscordColor.Black,
                Url          = GetProfileUrlForId(model.SteamID)
            };

            if (summary.ProfileVisibility != ProfileVisibility.Public)
            {
                em.Description = "This profile is private.";
                return(em);
            }

            em.AddField("Member since", summary.AccountCreatedDate.ToUniversalTime().ToString(), inline: true);

            if (summary.UserStatus != Steam.Models.SteamCommunity.UserStatus.Offline)
            {
                em.AddField("Status:", summary.UserStatus.ToString(), inline: true);
            }
            else
            {
                em.AddField("Last seen:", summary.LastLoggedOffDate.ToUniversalTime().ToString(), inline: true);
            }

            if (!string.IsNullOrWhiteSpace(summary.PlayingGameName))
            {
                em.AddField("Playing: ", summary.PlayingGameName);
            }

            if (!string.IsNullOrWhiteSpace(model.Location))
            {
                em.AddField("Location: ", model.Location);
            }

            // em.AddField("Game activity", $"{model.HoursPlayedLastTwoWeeks} hours past 2 weeks.", inline: true);

            if (model.IsVacBanned)
            {
                System.Collections.Generic.IReadOnlyCollection <PlayerBansModel> bans = this.user.GetPlayerBansAsync(model.SteamID).Result.Data;

                uint bancount = 0;
                foreach (PlayerBansModel b in bans)
                {
                    bancount += b.NumberOfVACBans;
                }

                em.AddField("VAC Status:", $"{Formatter.Bold(bancount.ToString())} ban(s) on record.", inline: true);
            }
            else
            {
                em.AddField("VAC Status:", "No bans registered");
            }

            return(em.Build());
        }