Merge pull request #37 from mavolin/35-modify-integration

This commit is contained in:
diamondburned 2020-05-10 16:50:47 -07:00 committed by GitHub
commit bc27d1481d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 19 deletions

View File

@ -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),
)
}

View File

@ -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 {

View File

@ -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
)