> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-Guild Script Trigger Reference

Reference for event triggers that call extended scripts



## Trigger

### createGuild

Creating guild

**Related methods:**
createGuild - Create Guild


#### Synchronous Execution Script

The script is executed synchronously before the creating guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow creating guild |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the creating guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### updateGuild

Update guild

**Related methods:**
updateGuild - Update Guild


#### Synchronous Execution Script

The script is executed synchronously before the update guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| oldGuild | [Guild](../sdk/#guild) | Guild before update |
| newGuild | [Guild](../sdk/#guild) | Guild after update |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow update guild |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local oldGuild = args.oldGuild
local newGuild = args.newGuild

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the update guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| oldGuild | [Guild](../sdk/#guild) | Guild before update |
| newGuild | [Guild](../sdk/#guild) | Guild after update |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local oldGuild = args.oldGuild
local newGuild = args.newGuild

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### joinGuild

Join guild

**Related methods:**
createGuild - Create Guild
createGuildByUserId - Create Guild by User ID
createGuildModelMaster - Create Guild Model Master


#### Synchronous Execution Script

The script is executed synchronously before the join guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |
| userId | string | User ID |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow join guild |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild
local userId = args.userId

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the join guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |
| userId | string | User ID |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild
local userId = args.userId

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### leaveGuild

Leave guild

**Related methods:**
deleteMember - Expel member
deleteMemberByGuildName - Expel member by specifying a Guild name


#### Synchronous Execution Script

The script is executed synchronously before the leave guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |
| userId | string | User ID |
| self | bool | Whether the user left the guild themselves or was removed by the guild master, or if the guild was disbanded |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow leave guild |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild
local userId = args.userId
local self = args.self

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the leave guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |
| userId | string | User ID |
| self | bool | Whether the user left the guild themselves or was removed by the guild master, or if the guild was disbanded |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild
local userId = args.userId
local self = args.self

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### changeRole

Change role

**Related methods:**
updateMemberRole - Update member role
updateMemberRoleByGuildName - Update member role by specifying a Guild name


#### Synchronous Execution Script

The script is executed synchronously before the change role process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |
| oldMembers | [Member[]](../sdk/#member) | Old Member Information |
| newMembers | [Member[]](../sdk/#member) | New Member Information |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow change role |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild
local oldMembers = args.oldMembers
local newMembers = args.newMembers

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the change role process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |
| oldMembers | [Member[]](../sdk/#member) | Old Member Information |
| newMembers | [Member[]](../sdk/#member) | New Member Information |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild
local oldMembers = args.oldMembers
local newMembers = args.newMembers

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### deleteGuild

Delete Guild

**Related methods:**
deleteGuild - Delete Guild


#### Synchronous Execution Script

The script is executed synchronously before the delete guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow delete guild |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the delete guild process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### receiveJoinRequest

Receive join request

**Related methods:**
sendRequest - Send a join request
sendRequestByUserId - Send a join request by specifying the user ID


#### Synchronous Execution Script

The script is executed synchronously before the receive join request process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |
| receiveMemberRequest | [ReceiveMemberRequest](../sdk/#receivememberrequest) | Join Request |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow receive join request |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild
local receiveMemberRequest = args.receiveMemberRequest

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the receive join request process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| guildModel | [GuildModel](../sdk/#guildmodel) | Guild Model |
| guild | [Guild](../sdk/#guild) | Guild |
| receiveMemberRequest | [ReceiveMemberRequest](../sdk/#receivememberrequest) | Join Request |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local guildModel = args.guildModel
local guild = args.guild
local receiveMemberRequest = args.receiveMemberRequest

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  



