Skip to main content

Manage Groups

Last updated on

Create a New Group

You can create a new group once you have a group configuration in your namespace. The members of your group will be admins by default.

FAccelByteModelsGroupRules GroupRules;

FAccelByteModelsCreateGroupRequest GroupConfiguration;

GroupConfiguration.GroupName = "MyNewGroupName";
GroupConfiguration.GroupType = EAccelByteGroupType::OPEN;
GroupConfiguration.GroupMaxMember = 25;
GroupConfiguration.GroupDescription = "MyNewGroupDescription";
GroupConfiguration.GroupIcon = "https://example.com";
GroupConfiguration.GroupRegion = "US";
GroupConfiguration.GroupRules = GroupRules;
GroupConfiguration.ConfigurationCode = "MyConfiguration Code";

FRegistry::Group.CreateGroup(
GroupConfiguration,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if CreateGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateGroup has an error
}));

Retrieve a List of Groups

Search for a group by its name or region. The results will be paginated, and you can use offset and limit parameters to limit the list. This function only shows PUBLIC and OPEN groups.

FAccelByteModelsGetGroupListRequest SearchConfiguration;

SearchConfiguration.GroupName = "SomeGroupName"; // You can leave it blank if you want to fetch all the groups
SearchConfiguration.GroupRegion = "US"; // You can leave it blank if you want to fetch all the groups
SearchConfiguration.Offset = 0;
SearchConfiguration.Limit = 99;

FRegistry::Group.GetGroupList(
SearchConfiguration,
THandler<FAccelByteModelsGetGroupListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetGroupListResponse& Result)
{
// Do something if GetGroupList has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupList has an error
}));

Retrieve Group Information

Get information about a group by using the Group ID.

FString groupId = "SomeGroupId";

FRegistry::Group.GetGroup(
groupId,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if GetGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroup has been successful
}));

Retrieve a Player's Group Information

You can get your current player's group information by using this function. If the player you requested doesn't belong to any group, the returned status will be ErrorCode.UserNotBelongToAnyGroup, and the player will be able to be invited to a group.

FString UserId = "CurrentPlayerUserId";

FRegistry::Group.GetUserGroupInfoByUserId(
UserId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if GetUserGroupInfoByUserId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetUserGroupInfoByUserId has an error
}));

Retrieve Other Player's Group Information

This function is to call the group information of other users with a specific user ID.

FString UserId = "OtherPlayerUserId";

FRegistry::Group.GetUserGroupInfoByUserId(
UserId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if GetUserGroupInfoByUserId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetUserGroupInfoByUserId has an error
}));

Retrieve a Group's Member List

Use this function to get a group's member list.

FString GroupId = "SomeGroupId";
FAccelByteModelsGetGroupMembersListByGroupIdRequest SearchGroupMemberConfiguration;

FRegistry::Group.GetGroupMembersListByGroupId(
GroupId,
SearchGroupMemberConfiguration,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if GetGroupMembersListByGroupId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupMembersListByGroupId has an error
}));

Update Group Information

A group's information such as its name, icon, description, region, and type can be updated with this function. Only members with an admin role can update the group's information.

FString GroupId = "SomeGroupId";
FAccelByteModelsGroupUpdatable UpdateGroupConfiguration;

FRegistry::Group.UpdateGroup(
GroupId,
True, // set True if you want to replace all group informations
UpdateGroupConfiguration,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroup has an error
}));

Update a Group's Custom Attributes

You can also update a group's custom attributes separately using this function. Just like the group information update, only members with an admin role can update the group's custom attributes.

FString GroupId = "SomeGroupId";
FAccelByteModelsUpdateGroupCustomAttributesRequest UpdateGroupCustomAttributeGroup;

FRegistry::Group.UpdateGroupCustomAttributes(
GroupId,
UpdateGroupCustomAttributeGroup,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroupCustomAttributes has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroupCustomAttributes has an error
}));