CommunityRoleClient
CommunityRoleClient:
TypedEventEmitter<CommunityRoleEvents> &object
Type declaration
create()
Parameters
| Parameter | Type |
|---|---|
request | CommunityRoleCreateRequest |
Returns
Promise<CommunityRole>
Example
import {
CommunityRole,
CommunityRoleCreateRequest,
CommunityRoleGuid,
CommunityPermission,
ChannelPermission,
rootServer,
} from "@rootsdk/server-bot";
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
| Parameter | Type |
|---|---|
request | CommunityRoleDeleteRequest |
Returns
Promise<void>
Example
import {
CommunityRole,
CommunityRoleDeleteRequest,
CommunityRoleGuid,
rootServer,
} from "@rootsdk/server-bot";
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
| Parameter | Type |
|---|---|
request | CommunityRoleEditRequest |
Returns
Promise<CommunityRole>
Example
import {
CommunityRole,
CommunityRoleEditRequest,
CommunityRoleGuid,
CommunityPermission,
ChannelPermission,
rootServer,
} from "@rootsdk/server-bot";
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
| Parameter | Type |
|---|---|
request | CommunityRoleGetRequest |
Returns
Promise<CommunityRole>
Example
import {
CommunityRole,
CommunityRoleGetRequest,
CommunityRoleGuid,
rootServer,
} from "@rootsdk/server-bot";
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-bot";
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;
}
}