Skip to main content

Requests

Overview

This section discusses methods for handling requests to join a channel (guild, chat, clan, and etc). As a rule, requests to join the channel owner come from other players. For example, players can send a request to join a clan or to participate in an in-game event. The channel owner can accept the membership request or reject it.

The service allows you to create the following types of requests:

  • ss.channels.acceptJoinRequest - ccepting a request to join +1 Request
  • ss.channels.rejectJoinRequest - rejection of a request to join +1 Request
  • ss.channels.fetchJoinRequests - get a list of incoming join requests in the selected channel +1 Request
  • ss.channels.fetchMoreJoinRequests - additionally load the list of incoming requests to join in the selected channel +1 Request
  • ss.channels.fetchSentJoinRequests - get a list of requests sent by a player to join channels +1 Request
  • ss.channels.fetchMoreSentJoinRequests - additionally load the list of requests sent by the player to join the channels +1 Request

Accepting a Request to Join

+1 Request

The player playerId: 123456 receives a request to join the channel channelId: 123. To do this, use the ss.channels.acceptJoinRequest method:

ss.channels.acceptJoinRequest({ channelId: 123, playerId: 123456 })

To get the result of a method call, you can subscribe to events:

ss.channels.on('acceptJoinRequest', () => {
// request received successfully
})

Execution with error:

ss.channels.on('error:acceptJoinRequest', (err) => {
// completed with an error
})

Possible errors are shown in the table below:

Basic ErrorsScript Errors
player_not_foundempty_channel_id
project_not_foundchannel_not_found
origin_not_allowedaccess_denied
player_bannedalready_in_channel
internal_errorchannel_capacity_reached

After sending the request, the player joins the channel and all players in the channel receive a notification about his entry:

ss.channels.on('event:join', (member) => {
// Channel ID
member.channelId
// Joined Player ID
member.id
// Player fields (avatar, name, custom fields)
member.state
// Player Mute Information
member.mute
})

Rejecting a Request to Join

+1 Request

Player playerId: 123456 rejects request to join channel channelId: 123. To do this, use the ss.channels.rejectJoinRequest method:

ss.channels.rejectJoinRequest({ channelId: 123, playerId: 123456 })

If the player - the owner of the channel rejects the request to join the channel, then a notification that someone rejected the request comes:

To get the result of a method call, you can subscribe to events:

ss.channels.on('rejectJoinRequest', () => {
// request successfully denied
})

Execution with error:

ss.channels.on('error:rejectJoinRequest', (err) => {
// completed with an error
})

Possible errors are shown in the table below:

Basic ErrorsScript Errors
player_not_foundempty_channel_id
project_not_foundchannel_not_found
origin_not_allowedaccess_denied
player_bannedjoin_request_not_found
internal_error
ss.channels.on('event:rejectJoinRequest', (joinRequest) => {
// Channel ID
joinRequest.channelId
// ID of the player who requested to join
joinRequest.playerId
})
tip

Requests can be declined by the player who owns the channel and other players in the channel (if they are allowed to accept join requests).

Get a List of Incoming Join Requests in the Selected Channel

+1 Request

To get a list of incoming join requests in the selected channel, use the method ss.channels.fetchJoinRequests:

const response = await ss.channels.fetchJoinRequests({
// Channel ID
channelId: 123,
// how much to request at a time, max. 100
limit: 100,
// how many entries to skip, max. 10000, used for page navigation or "load more"
offset: 0
})
tip

Mandatory access rights allowed to accept join requests

To get the result of a method call, you can subscribe to events:

ss.channels.on('fetchJoinRequests', (result) => {
result.items // array of membership requests list
result.canLoadMore // is it possible to load more requests

result.items.forEach((joinRequest) => {
// all request fields

// public fields of the player who submitted the request
joinRequest.player
joinRequest.player.id
joinRequest.player.name
joinRequest.player.avatar
// and other public fields

// date the request was sent, ISO 8601
invite.date
})
})

Execution with error:

ss.channels.on('error:fetchJoinRequests', (err) => {
// completed with an error
})

Possible errors are shown in the table below:

Basic ErrorsScript Errors
player_not_foundempty_channel_id
project_not_foundchannel_not_found
origin_not_allowedaccess_denied
player_banned
internal_error

To additionally upload membership requests, use the convenient method ss.channels.fetchMoreJoinRequests:

const response = await ss.channels.fetchMoreJoinRequests({
channelId: 123,
// how much to request at a time, max. 100
limit: 100
})

To get the result of a method call, you can subscribe to events:

ss.channels.on('fetchMoreJoinRequests', (result) => {
result.items // query list array
result.canLoadMore // is it possible to load more requests
})

Execution with error:

ss.channels.on('error:fetchMoreJoinRequests', (err) => {
// completed with an error
})

Possible errors are shown in the table below:

Basic ErrorsScript Errors
player_not_foundempty_channel_id
project_not_foundchannel_not_found
origin_not_allowedaccess_denied
player_banned
internal_error

Get a List of Requests Sent by a Player to Join

+1 Request

Get a list of requests sent by the player to join the various channels:

const response = await ss.channels.fetchSentJoinRequests({
// how much to request at a time, max. 100
limit: 100,
// how many entries to skip, max. 10000, used for page navigation or "load more"
offset: 0
})

To get the result of a method call, you can subscribe to events:

ss.channels.on('fetchSentJoinRequests', (result) => {
result.items // array of membership requests list
result.canLoadMore // is it possible to load more requests

result.items.forEach((joinRequest) => {
// all fields of the invite
// fields of the channel to which the other player is invited
joinRequest.channel
joinRequest.channel.id
joinRequest.channel.tags
joinRequest.channel.projectId
joinRequest.channel.capacity
joinRequest.channel.ownerId
joinRequest.channel.name
joinRequest.channel.description
joinRequest.channel.private
joinRequest.channel.visible
joinRequest.channel.hasPassword
joinRequest.channel.membersCount

// date the invitation was sent, ISO 8601
joinRequest.date
})
})

Execution with error:

ss.channels.on('error:fetchSentJoinRequests', (err) => {
// completed with an error
})

Possible errors are shown in the table below:

Basic Errors
player_not_found
project_not_found
origin_not_allowed
player_banned
internal_error

To additionally upload membership requests, use the convenient method ss.channels.fetchMoreSentJoinRequests:

const response = await ss.channels.fetchMoreSentJoinRequests({
// how much to request at a time, max. 100
limit: 100
})

To get the result of a method call, you can subscribe to events:

ss.channels.on('fetchMoreSentJoinRequests', (result) => {
result.items // array of membership requests list
result.canLoadMore // is it possible to load more requests
})

Execution with error:

ss.channels.on('error:fetchMoreSentJoinRequests', (err) => {
// completed with an error
})

Possible errors are shown in the table below:

Basic Errors
player_not_found
project_not_found
origin_not_allowed
player_banned
internal_error

Stay in Touch

Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.

SpellSync Community Telegram: @spellsync.

For your suggestions e-mail: [email protected]

We Wish you Success!