Beispiel #1
0
    def __get_server_and_member(self, discord_server, discord_user):
        member = Member.objects(discord=discord_user.id).first()
        server = Server.objects(id=discord_server.id).first()

        if not server:
            server = Server.create({
                'id': discord_server.id,
                'name': discord_server.name,
                'avatar': discord_server.icon_url or ''
            })

        if not member:
            member = Member.create({
                'discord': discord_user.id,
                'name': discord_user.name,
                'avatar': discord_user.avatar_url or ''
            })

        # Checks if member being added is in the server
        server_member = Member.objects(servers=discord_server.id,
                                       discord=discord_user.id).first()
        if not server_member:
            server.members.append(member)
            server.save()
            member.servers.append(discord_server.id)
            member.save()

        return (server, member)
Beispiel #2
0
member1.characters.append(char1)
member1.characters.append(char2)

member2 = Member.create({
    "discord": 2,
    "servers": [2],
    "name": "Test2",
    "avatar": "Some_Url2"
})
member2.characters.append(char3)

## Dummy Server Creation

server1 = Server.create({
    "id": 1,
    "name": "test_server1",
    "avatar": "Some_Url1"
})
server1.members.append(member1)

server2 = Server.create({
    "id": 2,
    "name": "test_server2",
    "avatar": "Some_Url2"
})
server2.members.append(member2)


def test_list():
    pass