1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-19 21:32:49 +00:00
arikawa/api/stage.go

61 lines
1.9 KiB
Go
Raw Normal View History

2021-05-29 19:09:41 +00:00
package api
import (
2021-06-02 02:53:19 +00:00
"github.com/diamondburned/arikawa/v3/discord"
"github.com/diamondburned/arikawa/v3/utils/httputil"
2021-05-29 19:09:41 +00:00
)
var EndpointStageInstances = Endpoint + "stage-instances/"
// https://discord.com/developers/docs/resources/stage-instance#create-stage-instance-json-params
type CreateStageInstanceData struct {
// ChannelID is the id of the Stage channel.
ChannelID discord.ChannelID `json:"channel_id"`
// Topic is the topic of the Stage instance (1-120 characters).
Topic string `json:"topic"`
// PrivacyLevel is the privacy level of the Stage instance.
//
// Defaults to discord.GuildOnlyStage.
PrivacyLevel discord.PrivacyLevel `json:"privacy_level,omitempty"`
}
// CreateStageInstance creates a new Stage instance associated to a Stage
// channel.
//
// It requires the user to be a moderator of the Stage channel.
func (c *Client) CreateStageInstance(
data CreateStageInstanceData) (*discord.StageInstance, error) {
var s *discord.StageInstance
return s, c.RequestJSON(
&s, "POST",
EndpointStageInstances,
httputil.WithJSONBody(data),
)
}
// https://discord.com/developers/docs/resources/stage-instance#update-stage-instance-json-params
type UpdateStageInstanceData struct {
// Topic is the topic of the Stage instance (1-120 characters).
Topic string `json:"topic,omitempty"`
// PrivacyLevel is the privacy level of the Stage instance.
PrivacyLevel discord.PrivacyLevel `json:"privacy_level,omitempty"`
}
// UpdateStageInstance updates fields of an existing Stage instance.
//
// It requires the user to be a moderator of the Stage channel.
func (c *Client) UpdateStageInstance(
channelID discord.ChannelID, data UpdateStageInstanceData) error {
return c.FastRequest(
"PATCH",
EndpointStageInstances+channelID.String(),
httputil.WithJSONBody(data),
)
}
func (c *Client) DeleteStageInstance(channelID discord.ChannelID) error {
return c.FastRequest("DELETE", EndpointStageInstances+channelID.String())
}