1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-15 19:33:17 +00:00
arikawa/discord/channel.go

84 lines
2.3 KiB
Go
Raw Normal View History

package discord
type Channel struct {
ID Snowflake `json:"id,string"`
Type ChannelType `json:"type"`
// Fields below may not appear
GuildID Snowflake `json:"guild_id,string,omitempty"`
Position int `json:"position,omitempty"`
Name string `json:"name,omitempty"` // 2-100 chars
Topic string `json:"topic,omitempty"` // 0-1024 chars
NSFW bool `json:"nsfw"`
Icon Hash `json:"icon,omitempty"`
// Direct Messaging fields
2020-01-04 04:19:24 +00:00
DMOwnerID Snowflake `json:"owner_id,string,omitempty"`
DMRecipients []User `json:"recipients,omitempty"`
// AppID of the group DM creator if it's bot-created
2020-01-04 04:19:24 +00:00
AppID Snowflake `json:"application_id,string,omitempty"`
// ID of the category the channel is in, if any.
2020-01-04 04:19:24 +00:00
CategoryID Snowflake `json:"parent_id,string,omitempty"`
LastPinTime Timestamp `json:"last_pin_timestamp,omitempty"`
// Explicit permission overrides for members and roles.
Permissions []Overwrite `json:"permission_overwrites,omitempty"`
// ID of the last message, may not point to a valid one.
2020-01-04 04:19:24 +00:00
LastMessageID Snowflake `json:"last_message_id,string,omitempty"`
// Slow mode duration. Bots and people with "manage_messages" or
// "manage_channel" permissions are unaffected.
UserRateLimit Seconds `json:"rate_limit_per_user,omitempty"`
// Voice, so GuildVoice only
2020-01-05 07:50:22 +00:00
VoiceBitrate uint `json:"bitrate,omitempty"`
VoiceUserLimit uint `json:"user_limit,omitempty"`
}
2020-01-24 05:45:47 +00:00
func (ch Channel) Mention() string {
return "<#" + ch.ID.String() + ">"
}
2020-03-05 23:49:44 +00:00
// IconURL returns the icon of the channel. This function will only return
// something if ch.Icon is not empty.
func (ch Channel) IconURL() string {
if ch.Icon == "" {
return ""
}
return "https://cdn.discordapp.com/channel-icons/" +
ch.ID.String() + "/" + ch.Icon + ".png"
}
type ChannelType uint8
2020-05-11 02:30:34 +00:00
var (
GuildText ChannelType = 0
DirectMessage ChannelType = 1
GuildVoice ChannelType = 2
GroupDM ChannelType = 3
GuildCategory ChannelType = 4
GuildNews ChannelType = 5
GuildStore ChannelType = 6
)
type Overwrite struct {
2020-01-04 04:19:24 +00:00
ID Snowflake `json:"id,string,omitempty"`
Type OverwriteType `json:"type"`
2020-01-04 04:19:24 +00:00
Allow Permissions `json:"allow"`
Deny Permissions `json:"deny"`
}
type OverwriteType string
const (
OverwriteRole OverwriteType = "role"
OverwriteMember OverwriteType = "member"
)