Skip to main content
Version: 5.11.2

Finding Guilds and Sending Join Requests

1. Write a method for finding guilds and sending join requests

Add content to the RequestGuildJoin method in BackendGuild.cs written in Pre-arrangements.

BackendGuild.cs

Before editing

    public void RequestGuildJoin(string guildName) {
// Step 3. Finding Guilds and Sending Join Requests
}

After editing

    public void RequestGuildJoin(string guildName) {
var bro = Backend.Guild.GetGuildIndateByGuildNameV3(guildName);

if(bro.IsSuccess() == false) {
Debug.LogError($"An error occurred while searching {guildName}. : " + bro);
return;
}

string guildInDate = bro.GetFlattenJSON()["guildInDate"].ToString();

bro = Backend.Guild.ApplyGuildV3(guildInDate);

if(bro.IsSuccess() == false) {
Debug.LogError($"An error occurred while sending a join request to {guildName}({guildInDate}). : " + bro);
return;
}

Debug.Log($"Successfully sent guild join request to {guildName}({guildInDate}). : " + bro);
}

2. Add method call to BackendManager.cs

BackendManager, which is automatically called when the game is executed, must be used to call this method.
Add it so that the method may be called after BACKND initialization and BACKND login.

At this time, the user to log in must differ from the user that called Step 2. Creating Guilds.

BackendManager.cs

Before editing(Step 2. Creating Guilds)

    async void Test() {
await Task.Run(() => {
BackendLogin.Instance.CustomLogin("user1", "1234"); // Logs in as user1
// When 412 error occurs while creating a guild, the creation of the guild is unavailable because the user already belongs to a guild.
// Create a new user with CustomSignUp("user3", "1234") to generate a guild.

BackendGuild.Instance.CreateGuild("Desired_guild_name"); // Method for creating guilds

Debug.Log("Test complete.");
});
}

After editing

    async void Test() {
await Task.Run(() => {

// When the method is called for the first time
BackendLogin.Instance.CustomSignUp("guildUser", "1234"); // New sign-up of user for the guild
BackendLogin.Instance.UpdateNickname("guildUser"); // Nickname registration of user for the guild

// When the method is called the second time
//BackendLogin.Instance.CustomLogin("guildUser", "1234"); // New sign-up of user for the guild

// The guild name entered in CreateGuild during Step 2 should be entered as the parameter value.
BackendGuild.Instance.RequestGuildJoin("Desired_guild_name");

Debug.Log("Test complete.");
});
}

4. Test in Unity

After editing the script, execute Unity debugging and check the console log of Unity.

The method has been successfully called when the log displays 'Successfully sent guild join request of OOO. : statusCode : 204'.
When errors such as statusCode : 400, 404, and 409 have occurred instead of the above log being displayed, you can check what errors caused the failure in GetGuildIndateByGuildNameV3 error case and ApplyGuildV3 error case.

Error case

Sign-up failed. : statusCode : 409
errorCode : DuplicatedParameterException

This is the case when the ID for the sign-up already exists. When the method is called twice, the error occurs because the method is called after the sign-up. Please use BackendLogin.Instance.CustomLogin shown as a footnote.