def get_user(member: Member, g: DBGuild = None) -> DBUser:
    if g is None:
        g = DBGuild.objects.get(g_id=member.guild.id)

    try:
        u = DBUser.objects.get(u_id=member.id, g=g)
        u.d_name = member.display_name
        u.is_bot = member.bot
        u.avatar_url = member.avatar_url
        u.save()
    except DBUser.DoesNotExist:
        try:
            u = DBUser(u_id=member.id,
                       u_name=member.display_name,
                       g=g,
                       is_bot=member.bot,
                       avatar_url=member.avatar_url)
            u.save()
        except IntegrityError:
            u = DBUser.objects.get(u_id=member.id, g=g)
            u.d_name = member.display_name
            u.is_bot = member.bot
            u.avatar_url = member.avatar_url
            u.save()

    return u
    def get_user(self, ctx: Context, u_id: Union[int, str]) -> Tuple[DBUser, Member]:

        m = None
        u_id = int(re.findall(r"\d+", u_id)[0]) if isinstance(u_id, str) else u_id

        for i in ctx.guild.members:
            if i.id == u_id:
                m = i
                break

        if m is not None:
            u = get_user(m, self.g)
        else:
            try:
                u = DBUser.objects.get(u_id=u_id, g=self.g)
            except DBUser.DoesNotExist:
                u = DBUser(u_id=u_id, g=self.g, u_name=m.display_name if m is not None else "")
                u.save()

        return u, m