Quick Reference for AI Agents & Developers// Update group details
const group = new CometChat.Group("group_guid", "New Name", CometChat.GROUP_TYPE.PUBLIC);
group.setDescription("New description");
group.setIcon("https://example.com/icon.png");
group.setMetadata({ department: "Engineering" });
group.setTags(["active", "priority"]);
const updated = await CometChat.updateGroup(group);
// Editable: name, icon, description, metadata, tags, owner
// Not editable: guid, type
Update group details like name, icon, description, and metadata.
Availability: SDK, API, UI KitsOnly admins and moderators can update group settings (depending on your configuration).
Update Group Details
JavaScript
TypeScript
Async/Await
const GUID = "group-123";
const groupName = "Updated Team Name";
const groupType = CometChat.GROUP_TYPE.PUBLIC;
const group = new CometChat.Group(GUID, groupName, groupType);
group.setDescription("New description for the team");
group.setIcon("https://example.com/new-icon.png");
CometChat.updateGroup(group).then(
(updatedGroup) => console.log("Group updated:", updatedGroup),
(error) => console.log("Failed to update:", error)
);
const GUID: string = "group-123";
const groupName: string = "Updated Team Name";
const groupType: string = CometChat.GROUP_TYPE.PUBLIC;
const group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType);
group.setDescription("New description for the team");
group.setIcon("https://example.com/new-icon.png");
CometChat.updateGroup(group).then(
(updatedGroup: CometChat.Group) => console.log("Group updated:", updatedGroup),
(error: CometChat.CometChatException) => console.log("Failed:", error)
);
const updateGroup = async () => {
try {
const GUID = "group-123";
const groupName = "Updated Team Name";
const groupType = CometChat.GROUP_TYPE.PUBLIC;
const group = new CometChat.Group(GUID, groupName, groupType);
group.setDescription("New description for the team");
group.setIcon("https://example.com/new-icon.png");
const updatedGroup = await CometChat.updateGroup(group);
console.log("Group updated:", updatedGroup);
} catch (error) {
console.log("Failed to update:", error);
}
};
Update Specific Properties
Update Name Only
const group = new CometChat.Group("group-123", "New Name", CometChat.GROUP_TYPE.PUBLIC);
CometChat.updateGroup(group).then(
(updated) => console.log("Name updated:", updated.getName()),
(error) => console.log("Failed:", error)
);
async function updateGroupName(guid, newName) {
try {
const group = new CometChat.Group(guid, newName, CometChat.GROUP_TYPE.PUBLIC);
const updated = await CometChat.updateGroup(group);
console.log("Name updated:", updated.getName());
return updated;
} catch (error) {
console.log("Failed:", error);
throw error;
}
}
Update Icon
const group = new CometChat.Group("group-123", "Team", CometChat.GROUP_TYPE.PUBLIC);
group.setIcon("https://example.com/new-icon.png");
CometChat.updateGroup(group).then(
(updated) => console.log("Icon updated:", updated.getIcon()),
(error) => console.log("Failed:", error)
);
async function updateGroupIcon(guid, iconUrl) {
try {
const group = new CometChat.Group(guid, "Team", CometChat.GROUP_TYPE.PUBLIC);
group.setIcon(iconUrl);
const updated = await CometChat.updateGroup(group);
console.log("Icon updated:", updated.getIcon());
return updated;
} catch (error) {
console.log("Failed:", error);
throw error;
}
}
const group = new CometChat.Group("group-123", "Team", CometChat.GROUP_TYPE.PUBLIC);
group.setMetadata({
department: "Engineering",
project: "Alpha",
priority: "high"
});
CometChat.updateGroup(group).then(
(updated) => console.log("Metadata updated:", updated.getMetadata()),
(error) => console.log("Failed:", error)
);
async function updateGroupMetadata(guid, metadata) {
try {
const group = new CometChat.Group(guid, "Team", CometChat.GROUP_TYPE.PUBLIC);
group.setMetadata(metadata);
const updated = await CometChat.updateGroup(group);
console.log("Metadata updated:", updated.getMetadata());
return updated;
} catch (error) {
console.log("Failed:", error);
throw error;
}
}
const group = new CometChat.Group("group-123", "Team", CometChat.GROUP_TYPE.PUBLIC);
group.setTags(["engineering", "priority", "active"]);
CometChat.updateGroup(group).then(
(updated) => console.log("Tags updated:", updated.getTags()),
(error) => console.log("Failed:", error)
);
async function updateGroupTags(guid, tags) {
try {
const group = new CometChat.Group(guid, "Team", CometChat.GROUP_TYPE.PUBLIC);
group.setTags(tags);
const updated = await CometChat.updateGroup(group);
console.log("Tags updated:", updated.getTags());
return updated;
} catch (error) {
console.log("Failed:", error);
throw error;
}
}
Editable Properties
| Property | Editable | Notes |
|---|
name | Yes | Display name |
icon | Yes | URL to group icon |
description | Yes | Group description |
metadata | Yes | Custom JSON data |
tags | Yes | Array of tags |
owner | Yes | Transfer ownership |
type | No | Cannot change after creation |
guid | No | Cannot change after creation |
Next Steps