コード例 #1
0
        public Task <BaseResult> Command_GetUserInfoAsync(
            [Name("Member")][Description("The user to get information for.")][DefaultValueDescription("The user who invoked this command.")]
            SocketUser member = null)
        {
            member = member ?? Context.Invoker;

            var embed = new EmbedBuilder
            {
                ThumbnailUrl = member.GetEffectiveAvatarUrl(256),
                Title        = $"Information for user {member}",
                Color        = member.GetHighestRoleColourOrDefault()
            };

            embed.AddField("Created", FormatOffset(member.CreatedAt), true);

            if (member is SocketGuildUser guildUser)
            {
                if (guildUser.JoinedAt != null)
                {
                    embed.AddField("Joined", FormatOffset(guildUser.JoinedAt.Value), true);
                }
                embed.AddField("Position",
                               guildUser.Hierarchy == int.MaxValue ? "Server Owner" : "Position " + guildUser.Hierarchy, true);

                embed.AddField("Deafened", guildUser.IsDeafened, true);
                embed.AddField("Muted", guildUser.IsMuted, true);
                embed.AddField("Nickname", guildUser.Nickname ?? "None", true);
                embed.AddField("Voice Status", GetVoiceChannelStatus(guildUser), true);

                var roles       = guildUser.Roles.Where(r => !r.IsEveryone);
                var socketRoles = roles as SocketRole[] ?? roles.ToArray();
                if (socketRoles.Length != 0)
                {
                    embed.AddField("Roles", string.Join(", ", socketRoles.Select(r => r.Name)));
                }
            }

            if (member.Activity != null)
            {
                embed.AddField("Activity",
                               $"{member.Activity.Type.Humanize()} {member.Activity.Name}", true);
            }
            embed.AddField("Status", member.Status.Humanize(), true);
            embed.AddField("Is Bot or Webhook", member.IsBot || member.IsWebhook, true);

            return(Ok(embed));
        }