예제 #1
0
        // Casts DiscordUser to DiscordMember w/ a given guild.
        // May fail (return null) if the guild doesn't contain the user.
        public static DiscordMember?ToDiscordMember(
            this DiscordUser user,
            DiscordGuild guild
            )
        {
            foreach (DiscordMember member in guild.Members.Values)
            {
                if (member.Id == user.Id)
                {
                    return(member);
                }
            }
            string warning =
                "DiscordMember conversion failed: " +
                user.Userstring() + " - " + guild.Name;

            log.Warning(warning);
            return(null);
        }