mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-17 12:23:08 +00:00
discord/api: Add StageInstances
This commit is contained in:
parent
4595c87e36
commit
5a1837a094
60
api/stage.go
Normal file
60
api/stage.go
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/diamondburned/arikawa/v2/discord"
|
||||||
|
"github.com/diamondburned/arikawa/v2/utils/httputil"
|
||||||
|
)
|
||||||
|
|
||||||
|
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())
|
||||||
|
}
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"github.com/diamondburned/arikawa/v2/utils/json"
|
"github.com/diamondburned/arikawa/v2/utils/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Channel represents a guild or DM channel within Discord.
|
||||||
|
//
|
||||||
// https://discord.com/developers/docs/resources/channel#channel-object
|
// https://discord.com/developers/docs/resources/channel#channel-object
|
||||||
type Channel struct {
|
type Channel struct {
|
||||||
// ID is the id of this channel.
|
// ID is the id of this channel.
|
||||||
|
@ -162,6 +164,20 @@ const (
|
||||||
// GuildStore is a channel in which game developers can sell their game on
|
// GuildStore is a channel in which game developers can sell their game on
|
||||||
// Discord.
|
// Discord.
|
||||||
GuildStore
|
GuildStore
|
||||||
|
_
|
||||||
|
_
|
||||||
|
_
|
||||||
|
// GuildNewsThread is a temporary sub-channel within a GUILD_NEWS channel
|
||||||
|
GuildNewsThread
|
||||||
|
// GuildPublicThread is a temporary sub-channel within a GUILD_TEXT
|
||||||
|
// channel.
|
||||||
|
GuildPublicThread
|
||||||
|
// GuildPrivateThread isa temporary sub-channel within a GUILD_TEXT channel
|
||||||
|
// that is only viewable by those invited and those with the MANAGE_THREADS
|
||||||
|
// permission.
|
||||||
|
GuildPrivateThread
|
||||||
|
// GuildStageVoice is a voice channel for hosting events with an audience.
|
||||||
|
GuildStageVoice
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/channel#overwrite-object
|
// https://discord.com/developers/docs/resources/channel#overwrite-object
|
||||||
|
|
|
@ -250,6 +250,20 @@ func (s RoleID) PID() uint8 { return Snowflake(s).PID() }
|
||||||
func (s RoleID) Increment() uint16 { return Snowflake(s).Increment() }
|
func (s RoleID) Increment() uint16 { return Snowflake(s).Increment() }
|
||||||
func (s RoleID) Mention() string { return "<@&" + s.String() + ">" }
|
func (s RoleID) Mention() string { return "<@&" + s.String() + ">" }
|
||||||
|
|
||||||
|
type StageID Snowflake
|
||||||
|
|
||||||
|
const NullStageID = StageID(NullSnowflake)
|
||||||
|
|
||||||
|
func (s StageID) MarshalJSON() ([]byte, error) { return Snowflake(s).MarshalJSON() }
|
||||||
|
func (s *StageID) UnmarshalJSON(v []byte) error { return (*Snowflake)(s).UnmarshalJSON(v) }
|
||||||
|
func (s StageID) String() string { return Snowflake(s).String() }
|
||||||
|
func (s StageID) IsValid() bool { return Snowflake(s).IsValid() }
|
||||||
|
func (s StageID) IsNull() bool { return Snowflake(s).IsNull() }
|
||||||
|
func (s StageID) Time() time.Time { return Snowflake(s).Time() }
|
||||||
|
func (s StageID) Worker() uint8 { return Snowflake(s).Worker() }
|
||||||
|
func (s StageID) PID() uint8 { return Snowflake(s).PID() }
|
||||||
|
func (s StageID) Increment() uint16 { return Snowflake(s).Increment() }
|
||||||
|
|
||||||
type StickerID Snowflake
|
type StickerID Snowflake
|
||||||
|
|
||||||
const NullStickerID = StickerID(NullSnowflake)
|
const NullStickerID = StickerID(NullSnowflake)
|
||||||
|
|
31
discord/stage.go
Normal file
31
discord/stage.go
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package discord
|
||||||
|
|
||||||
|
// A StageInstance holds information about a live stage instance.
|
||||||
|
//
|
||||||
|
// https://discord.com/developers/docs/resources/stage-instance#stage-instance-object
|
||||||
|
type StageInstance struct {
|
||||||
|
// ID is the id of this Stage instance.
|
||||||
|
ID StageID `json:"id"`
|
||||||
|
// GuildID is the guild id of the associated Stage channel.
|
||||||
|
GuildID GuildID `json:"guild_id"`
|
||||||
|
// ChannelID is the id of the associated Stage channel.
|
||||||
|
ChannelID 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.
|
||||||
|
PrivacyLevel PrivacyLevel `json:"privacy_level"`
|
||||||
|
// NotDiscoverable defines whether or not Stage discovery is disabled.
|
||||||
|
NotDiscoverable bool `json:"discoverable_disabled"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrivacyLevel int
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
|
||||||
|
const (
|
||||||
|
// PublicStage is used if a StageInstance instance is visible publicly, such as on
|
||||||
|
// StageInstance discovery.
|
||||||
|
PublicStage PrivacyLevel = iota + 1
|
||||||
|
// GuildOnlyStage is used if a StageInstance instance is visible to only guild
|
||||||
|
// members.
|
||||||
|
GuildOnlyStage
|
||||||
|
)
|
Loading…
Reference in a new issue