Skip to main content
Version: 5.9.6

apply-request

BACKND Guidelines > 9. Implementing Guild Functions > Step 4. Accepting Guild Join Requests

Accepting Guild Join Requests

1. Write a method for accepting guild join requests

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

BackendGuild.cs

Before editing

    public void AcceptGuildJoinRequest(int index) {
// Step 4. Accepting Guild Join Requests
}

After editing

    public void AcceptGuildJoinRequest(int index) {
var bro = Backend.Guild.GetApplicantsV3();

if(bro.IsSuccess() == false) {
Debug.LogError("An error occurred while loading the list of users who requested to join the guild. : " + bro);
return;
}

Debug.Log("Successfully loaded the list of users who requested to join the guild. : " + bro);


if(bro.FlattenRows().Count <= 0) {
Debug.LogError("There are no users who requested to join. : " + bro);
return;
}

List<Tuple<string, string>> requestUserList = new List<Tuple<string, string>>();

foreach(LitJson.JsonData requestJson in bro.FlattenRows()) {
requestUserList.Add(new Tuple<string, string>(requestJson["nickname"].ToString(), requestJson["inDate"].ToString()));
}

string userString = "Join request list\n";

for(int i = 0; i < requestUserList.Count; i++) {
userString += $"{index}. {requestUserList[i].Item1}({requestUserList[i].Item2})\n";
}

Debug.Log(userString);

bro = Backend.Guild.ApproveApplicantV3(requestUserList[index].Item2);
if(bro.IsSuccess() == false) {
Debug.LogError($"An error occurred while approving the join request of {requestUserList[index].Item1}({requestUserList[index].Item2}). : " + bro);
return;
}

Debug.Log($"Successfully accepted the join request of {requestUserList[index].Item1}({requestUserList[index].Item2}).: " + 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 be the one that called Step 2. Creating Guilds.

BackendManager.cs

Before editing

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

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

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

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

After editing

    async void Test() {
await Task.Run(() => {
BackendLogin.Instance.CustomLogin("user1", "1234"); // Must be logged in as the user who created the guild in Step 2.

BackendGuild.Instance.AcceptGuildJoinRequest(0); // From users who sent join requests, accepts the one who sent the most recent request.

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

3. 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 accepted the join request from OO. : statusCode : 204'.
When errors, such as statusCode : 400, 404, and 409, occur instead of the above log, you can check which errors caused the failure in ApproveApplicantV3 and GetApplicantsV3 error case.

4. Check in the console

Go to BACKND Base, and in BACKND Base > Guild Management, click the created guild and check that the member count has increased.