mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-27 17:23:00 +00:00
Merge pull request #37 from mavolin/35-modify-integration
This commit is contained in:
commit
bc27d1481d
27
api/guild.go
27
api/guild.go
|
@ -233,25 +233,18 @@ func (c *Client) AttachIntegration(
|
|||
)
|
||||
}
|
||||
|
||||
// https://discord.com/developers/docs/resources/guild#modify-guild-integration-json-params
|
||||
type ModifyIntegrationData struct {
|
||||
ExpireBehavior *discord.ExpireBehavior `json:"expire_behavior"`
|
||||
ExpireGracePeriod json.OptionInt `json:"expire_grace_period"`
|
||||
EnableEmoticons json.OptionBool `json:"enable_emoticons"` // limited to twitch
|
||||
}
|
||||
|
||||
// ModifyIntegration requires MANAGE_GUILD.
|
||||
func (c *Client) ModifyIntegration(
|
||||
guildID, integrationID discord.Snowflake,
|
||||
expireBehavior, expireGracePeriod int, emoticons bool) error {
|
||||
|
||||
var param struct {
|
||||
ExpireBehavior int `json:"expire_behavior"`
|
||||
ExpireGracePeriod int `json:"expire_grace_period"`
|
||||
EnableEmoticons bool `json:"enable_emoticons"`
|
||||
}
|
||||
|
||||
param.ExpireBehavior = expireBehavior
|
||||
param.ExpireGracePeriod = expireGracePeriod
|
||||
param.EnableEmoticons = emoticons
|
||||
|
||||
func (c *Client) ModifyIntegration(guildID, integrationID discord.Snowflake, data ModifyIntegrationData) error {
|
||||
return c.FastRequest(
|
||||
"PATCH",
|
||||
EndpointGuilds+guildID.String()+"/integrations/"+integrationID.String(),
|
||||
httputil.WithSchema(c, param),
|
||||
"PATCH", EndpointGuilds+guildID.String()+"/integrations/"+integrationID.String(),
|
||||
httputil.WithJSONBody(data),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ type Integration struct {
|
|||
// used for subscribers
|
||||
RoleID Snowflake `json:"role_id"`
|
||||
|
||||
ExpireBehavior int `json:"expire_behavior"`
|
||||
ExpireGracePeriod int `json:"expire_grace_period"`
|
||||
ExpireBehavior ExpireBehavior `json:"expire_behavior"`
|
||||
ExpireGracePeriod int `json:"expire_grace_period"`
|
||||
|
||||
User User `json:"user"`
|
||||
Account struct {
|
||||
|
|
|
@ -88,3 +88,13 @@ const (
|
|||
Twitch Service = "twitch"
|
||||
YouTube Service = "youtube"
|
||||
)
|
||||
|
||||
// ExpireBehavior is the integration expire behavior that regulates what happens, if a subscriber expires.
|
||||
type ExpireBehavior uint8
|
||||
|
||||
var (
|
||||
// RemoveRole removes the role of the subscriber.
|
||||
RemoveRole ExpireBehavior = 0
|
||||
// Kick kicks the subscriber from the guild.
|
||||
Kick ExpireBehavior = 1
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue