Skip to main content

CommunityRoleClient

CommunityRoleClient: TypedEventEmitter<CommunityRoleEvents> & object

Type declaration

create()

Parameters

ParameterType
requestCommunityRoleCreateRequest

Returns

Promise<CommunityRole>

Example

import {
CommunityRole,
CommunityRoleCreateRequest,
CommunityRoleGuid,
CommunityPermission,
ChannelPermission,
rootServer,
} from "@rootsdk/server-app";

export async function createExample(): Promise<CommunityRole> {
try {
// Set up the request
const request: CommunityRoleCreateRequest = {
name: "MyCommunityRole",
colorHex: "#00FF00",
communityPermission: {
communityManageCommunity: false,
communityManageRoles: false,
communityManageEmojis: false,
communityManageAuditLog: false,
communityCreateInvite: false,
communityManageInvites: false,
communityCreateBan: false,
communityManageBans: false,
communityFullControl: false,
communityKick: false,
communityChangeMyNickname: false,
communityChangeOtherNickname: false,
communityCreateChannelGroup: false,
communityManageApps: false,
},
channelPermission: {
channelFullControl: false,
channelView: true,
channelUseExternalEmoji: false,
channelCreateMessage: true,
channelDeleteMessageOther: false,
channelManagePinnedMessages: false,
channelViewMessageHistory: false,
channelCreateMessageAttachment: false,
channelCreateMessageMention: false,
channelCreateMessageReaction: false,
channelMakeMessagePublic: false,
channelMoveUserOther: false,
channelVoiceTalk: false,
channelVoiceMuteOther: false,
channelVoiceDeafenOther: false,
channelVoiceKick: false,
channelVideoStreamMedia: false,
channelCreateFile: false,
channelManageFiles: false,
channelViewFile: false,
channelAppKick: false,
},
};

// Call the API
const communityRole: CommunityRole =
await rootServer.community.communityRoles.create(request);

return communityRole;
} catch (error) {
// Detect error
throw error;
}
}

delete()

Parameters

ParameterType
requestCommunityRoleDeleteRequest

Returns

Promise<void>

Example

import {
CommunityRole,
CommunityRoleDeleteRequest,
CommunityRoleGuid,
rootServer,
} from "@rootsdk/server-app";

export async function deleteExample(
communityRoleId: CommunityRoleGuid,
): Promise<void> {
try {
// Set up the request
const request: CommunityRoleDeleteRequest = {
id: communityRoleId,
};

// Call the API
await rootServer.community.communityRoles.delete(request);
} catch (error) {
// Detect error
throw error;
}
}

edit()

Parameters

ParameterType
requestCommunityRoleEditRequest

Returns

Promise<CommunityRole>

Example

import {
CommunityRole,
CommunityRoleEditRequest,
CommunityRoleGuid,
CommunityPermission,
ChannelPermission,
rootServer,
} from "@rootsdk/server-app";

export async function editExample(
communityRoleId: CommunityRoleGuid,
): Promise<CommunityRole> {
try {
// Set up the request
const request: CommunityRoleEditRequest = {
id: communityRoleId,
name: "MyCommunityRole",
colorHex: "#00FF00",
communityPermission: {
communityManageCommunity: false,
communityManageRoles: false,
communityManageEmojis: false,
communityManageAuditLog: false,
communityCreateInvite: false,
communityManageInvites: false,
communityCreateBan: false,
communityManageBans: false,
communityFullControl: false,
communityKick: false,
communityChangeMyNickname: false,
communityChangeOtherNickname: false,
communityCreateChannelGroup: false,
communityManageApps: false,
},
channelPermission: {
channelFullControl: false,
channelView: true,
channelUseExternalEmoji: false,
channelCreateMessage: true,
channelDeleteMessageOther: false,
channelManagePinnedMessages: false,
channelViewMessageHistory: true,
channelCreateMessageAttachment: false,
channelCreateMessageMention: false,
channelCreateMessageReaction: false,
channelMakeMessagePublic: false,
channelMoveUserOther: false,
channelVoiceTalk: false,
channelVoiceMuteOther: false,
channelVoiceDeafenOther: false,
channelVoiceKick: false,
channelVideoStreamMedia: false,
channelCreateFile: false,
channelManageFiles: false,
channelViewFile: false,
channelAppKick: false,
},
};

// Call the API
const communityRole: CommunityRole =
await rootServer.community.communityRoles.edit(request);

return communityRole;
} catch (error) {
// Detect error
throw error;
}
}

get()

Parameters

ParameterType
requestCommunityRoleGetRequest

Returns

Promise<CommunityRole>

Example

import {
CommunityRole,
CommunityRoleGetRequest,
CommunityRoleGuid,
rootServer,
} from "@rootsdk/server-app";

export async function getExample(
communityRoleId: CommunityRoleGuid,
): Promise<CommunityRole> {
try {
// Set up the request
const request: CommunityRoleGetRequest = {
id: communityRoleId,
};

// Call the API
const communityRole: CommunityRole =
await rootServer.community.communityRoles.get(request);

return communityRole;
} catch (error) {
// Detect error
throw error;
}
}

list()

Returns

Promise<CommunityRole[]>

Example

import {
CommunityRole,
CommunityRoleGuid,
rootServer,
} from "@rootsdk/server-app";

export async function listExample(): Promise<CommunityRole[]> {
try {
// Call the API
const communityRoles: CommunityRole[] =
await rootServer.community.communityRoles.list();

return communityRoles;
} catch (error) {
// Detect error
throw error;
}
}