Skip to main content

CommunityMemberBanClient

CommunityMemberBanClient: TypedEventEmitter<CommunityMemberBanEvents> & object

Type declaration

create()

Parameters

ParameterType
requestCommunityMemberBanCreateRequest

Returns

Promise<CommunityMemberBan>

Example

import {
CommunityMemberBan,
CommunityMemberBanCreateRequest,
UserGuid,
rootServer,
} from "@rootsdk/server-bot";

export async function createExample(
userId: UserGuid,
): Promise<CommunityMemberBan> {
try {
// Set up the request
const request: CommunityMemberBanCreateRequest = {
userId: userId,
reason: "Why the user should be banned from the community",
expiresAt: undefined,
};

// Call the API
const communityMemberBan: CommunityMemberBan =
await rootServer.community.communityMemberBans.create(request);

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

delete()

Parameters

ParameterType
requestCommunityMemberBanDeleteRequest

Returns

Promise<void>

Example

import {
CommunityMemberBan,
CommunityMemberBanDeleteRequest,
UserGuid,
rootServer,
} from "@rootsdk/server-bot";

export async function deleteExample(userId: UserGuid): Promise<void> {
try {
// Set up the request
const request: CommunityMemberBanDeleteRequest = {
userId: userId,
};

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

get()

Parameters

ParameterType
requestCommunityMemberBanGetRequest

Returns

Promise<CommunityMemberBan>

Example

import {
CommunityMemberBan,
CommunityMemberBanGetRequest,
UserGuid,
rootServer,
} from "@rootsdk/server-bot";

export async function getExample(
userId: UserGuid,
): Promise<CommunityMemberBan> {
try {
// Set up the request
const request: CommunityMemberBanGetRequest = {
userId: userId,
};

// Call the API
const communityMemberBan =
await rootServer.community.communityMemberBans.get(request);

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

kick()

Parameters

ParameterType
requestCommunityMemberBanKickRequest

Returns

Promise<void>

Example

import {
CommunityMemberBan,
CommunityMemberBanKickRequest,
UserGuid,
rootServer,
} from "@rootsdk/server-bot";

export async function kickExample(userId: UserGuid): Promise<void> {
try {
// Set up the request
const request: CommunityMemberBanKickRequest = {
userId: userId,
};

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

list()

Returns

Promise<CommunityMemberBan[]>

Example

import { CommunityMemberBan, rootServer } from "@rootsdk/server-bot";

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

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