Пример #1
0
        public async Task UserInfo ([Remainder] IGuildUser user)
        {
            var options = GetOptions<UserInfoOptions> ();

            EmbedBuilder emb = new EmbedBuilder();

            string userRoles = DiscordHelpers.GetListOfUsersRoles (user);
            IRole highestRole = DiscordHelpers.GetUsersHigherstRole (user);

            if (highestRole != null)
                emb.Color = highestRole.Color;
            EmbedAuthorBuilder author = new EmbedAuthorBuilder ();
            author.Name = user.Username;
            if (user.IsBot)
                author.Name += " (Bot)";
            else if (user.IsWebhook)
                author.Name += " (Webhook)";

            emb.Author = author;
            if (string.IsNullOrEmpty (user.AvatarId))
                emb.ThumbnailUrl = $"https://discordapp.com/assets/dd4dbc0016779df1378e7812eabaa04d.png";
            else
                emb.ThumbnailUrl = $"https://cdn.discordapp.com/avatars/{user.Id}/{user.AvatarId}.png";

            EmbedFooterBuilder footer = new EmbedFooterBuilder();
            footer.Text = $"User info requested by {Context.User.Username}";
            if (string.IsNullOrEmpty (Context.User.AvatarId))
                footer.IconUrl = $"https://discordapp.com/assets/dd4dbc0016779df1378e7812eabaa04d.png";
            else
                footer.IconUrl = $"https://cdn.discordapp.com/avatars/{Context.User.Id}/{Context.User.AvatarId}.png";
            emb.Footer = footer;

            emb.Description = $"User information for {user.Username}#{user.Discriminator} | {user.Id}";

            emb.AddField("Created account at", user.CreatedAt.ToString("dd MMM yyyy, HH:mm"));

            emb.AddField("Joined server at", ((DateTimeOffset)user.JoinedAt).ToString("dd MMM yyyy, HH:mm"));
            if (string.IsNullOrEmpty(userRoles) == false)
                emb.AddField("Role(s)", userRoles);

            // Display the list of all of user's permissions
            string userPermissions = GetUserPermissions (user);

            if (string.IsNullOrEmpty (userPermissions) == false)
                emb.AddField ("Permissions", userPermissions);

            emb.AddField("Online status", user.Status == UserStatus.DoNotDisturb ? "Do Not Disturb" : user.Status.ToString());

            if (user.Game.HasValue)
            {
                if (user.Game.Value.StreamType == StreamType.Twitch)
                {
                    emb.AddField("Streaming", user.Game.Value.StreamUrl);
                }
                else
                {
                    emb.AddField("Playing", user.Game.Value.Name);
                }
            }

            await SendMessage (options, "", false, emb.Build());
        }