# Adding Friends (Godot)

**URL:** <https://forum.heroiclabs.com/t/adding-friends-godot/1008>\
**Category:** Local Setup\
**Created:** [September 28, 2020, 5:22pm UTC](https://forum.heroiclabs.com/t/adding-friends-godot/1008 "2020-09-28T17:22:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Korama](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@Korama](https://forum.heroiclabs.com/u/Korama)\
**Post date:** [September 28, 2020, 5:22pm UTC](https://forum.heroiclabs.com/t/adding-friends-godot/1008/1 "2020-09-28T17:22:47Z")

</div>

Hi Heroic Labs,

I’m trying to add friends in Godot + Nakama, and I was just wondering if it’s possible to add a friend by username alone? I’m using the “Add friends” function suggested in [https://heroiclabs.com/docs/social-friends/](https://heroiclabs.com/docs/social-friends/) which hints that you can use “username” or “id”, but the add\_friends\_async function takes 3 arguments (session, user\_id, username) and I’ve only got 2; the session and friend’s username.

Thank you!

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [September 28, 2020, 8:43pm UTC](https://forum.heroiclabs.com/t/adding-friends-godot/1008/2 "2020-09-28T20:43:21Z")

</div>

Hi @Korama welcome 👋

> I was just wondering if it’s possible to add a friend by username alone?

Yes, the server supports the option to add users as friends by user ID or username.

> the add\_friends\_async function takes 3 arguments (session, user\_id, username) and I’ve only got 2; the session and friend’s username.

You should be able to pass in `null` to skip over the input. The function arguments can be seen in the client code:

[https://github.com/heroiclabs/nakama-godot/blob/master/addons/com.heroiclabs.nakama/api/NakamaAPI.gd#L3453-L3458](https://github.com/heroiclabs/nakama-godot/blob/master/addons/com.heroiclabs.nakama/api/NakamaAPI.gd#L3453-L3458)

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Korama](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@Korama](https://forum.heroiclabs.com/u/Korama)\
**Post date:** [September 28, 2020, 9:35pm UTC](https://forum.heroiclabs.com/t/adding-friends-godot/1008/3 "2020-09-28T21:35:33Z")

</div>

Thank you so much, it works now!

Although… It required some alteration of the NakamaClient.gd to accept null as an argument:

func add\_friends\_async(p\_session : NakamaSession, p\_ids : PoolStringArray, p\_usernames = null) -\> NakamaAsyncResult:

_got changed to_

func add\_friends\_async(p\_session : NakamaSession, p\_ids = null, p\_usernames = null) -\> NakamaAsyncResult:

and now it works. Am I missing a trick/have I broken something?

Much appreciate the help 👍

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [September 29, 2020, 3:20am UTC](https://forum.heroiclabs.com/t/adding-friends-godot/1008/4 "2020-09-29T03:20:28Z")

</div>

> Am I missing a trick/have I broken something?

@Korama I’m glad you’ve solved it. I think you’ve found a limitation in the code generator used to create the `NakamaClient.gd` code. Please can you open an issue on the Godot client codebase and we can improve it. 🙂

---

<div class="post-metadata">

**Author:** ![Korama](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@Korama](https://forum.heroiclabs.com/u/Korama)\
**Post date:** [September 29, 2020, 2:33pm UTC](https://forum.heroiclabs.com/t/adding-friends-godot/1008/5 "2020-09-29T14:33:21Z")

</div>

It’s fixed now on the main branch, looks like it was my mistake - I was using an older version of Nakama + Godot.

Thank you.
