models

package
v0.0.0-...-d1147f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxClones   = 20
	DefaultMaxChannels = 10
)
View Source
const (
	// Deprecated: DiscordPermReadMessages has been replaced with DiscordPermViewChannel for text and voice channels.
	DiscordPermReadMessages       = 0x0000000000000400
	DiscordPermSendMessages       = 0x0000000000000800
	DiscordPermSendTTSMessages    = 0x0000000000001000
	DiscordPermManageMessages     = 0x0000000000002000
	DiscordPermEmbedLinks         = 0x0000000000004000
	DiscordPermAttachFiles        = 0x0000000000008000
	DiscordPermReadMessageHistory = 0x0000000000010000
	DiscordPermMentionEveryone    = 0x0000000000020000
	DiscordPermUseExternalEmojis  = 0x0000000000040000
	DiscordPermUseSlashCommands   = 0x0000000080000000
)

Constants for the different bit offsets of text channel permissions.

View Source
const (
	DiscordPermVoicePrioritySpeaker = 0x0000000000000100
	DiscordPermVoiceStreamVideo     = 0x0000000000000200
	DiscordPermVoiceConnect         = 0x0000000000100000
	DiscordPermVoiceSpeak           = 0x0000000000200000
	DiscordPermVoiceMuteMembers     = 0x0000000000400000
	DiscordPermVoiceDeafenMembers   = 0x0000000000800000
	DiscordPermVoiceMoveMembers     = 0x0000000001000000
	DiscordPermVoiceUseVAD          = 0x0000000002000000
	DiscordPermVoiceRequestToSpeak  = 0x0000000100000000
)

Constants for the different bit offsets of voice permissions.

View Source
const (
	DiscordPermChangeNickname  = 0x0000000004000000
	DiscordPermManageNicknames = 0x0000000008000000
	DiscordPermManageRoles     = 0x0000000010000000
	DiscordPermManageWebhooks  = 0x0000000020000000
	DiscordPermManageEmojis    = 0x0000000040000000
)

Constants for general management.

View Source
const (
	DiscordPermCreateInstantInvite = 0x0000000000000001
	DiscordPermKickMembers         = 0x0000000000000002
	DiscordPermBanMembers          = 0x0000000000000004
	DiscordPermAdministrator       = 0x0000000000000008
	DiscordPermManageChannels      = 0x0000000000000010
	DiscordPermManageServer        = 0x0000000000000020
	DiscordPermAddReactions        = 0x0000000000000040
	DiscordPermViewAuditLogs       = 0x0000000000000080
	DiscordPermViewChannel         = 0x0000000000000400
	DiscordPermViewGuildInsights   = 0x0000000000080000

	DiscordPermAllText = DiscordPermViewChannel |
		DiscordPermSendMessages |
		DiscordPermSendTTSMessages |
		DiscordPermManageMessages |
		DiscordPermEmbedLinks |
		DiscordPermAttachFiles |
		DiscordPermReadMessageHistory |
		DiscordPermMentionEveryone
	DiscordPermAllVoice = DiscordPermViewChannel |
		DiscordPermVoiceConnect |
		DiscordPermVoiceSpeak |
		DiscordPermVoiceMuteMembers |
		DiscordPermVoiceDeafenMembers |
		DiscordPermVoiceMoveMembers |
		DiscordPermVoiceUseVAD |
		DiscordPermVoicePrioritySpeaker
	DiscordPermAllChannel = DiscordPermAllText |
		DiscordPermAllVoice |
		DiscordPermCreateInstantInvite |
		DiscordPermManageRoles |
		DiscordPermManageChannels |
		DiscordPermAddReactions |
		DiscordPermViewAuditLogs
	DiscordPermAll = DiscordPermAllChannel |
		DiscordPermKickMembers |
		DiscordPermBanMembers |
		DiscordPermManageServer |
		DiscordPermAdministrator |
		DiscordPermManageWebhooks |
		DiscordPermManageEmojis
)

Constants for the different bit offsets of general permissions.

View Source
const (
	RoleSystemAdmin = "system_admin"
	RoleUser        = "user"
)

Variables

View Source
var DefaultChannelMatch = regexp.MustCompile(`^.* \+$`)

Functions

func IsDatabaseError

func IsDatabaseError(err error) bool

Types

type ConfigDatabase

type ConfigDatabase struct {
	URL      string `env:"URL"      long:"url" required:"true" description:"database connection url"`
	Username string `env:"USERNAME" long:"username" description:"database username if not specified via the URL"`
	Password string `env:"PASSWORD" long:"password" description:"database password if not specified via the URL"`
	Database string `env:"DATABASE" long:"database" description:"database name if not specified via the URL"`
}

ConfigDatabase holds the database configuration.

type ConfigDiscord

type ConfigDiscord struct {
	ClientID     string   `env:"CLIENT_ID"     long:"client-id"     required:"true" description:"Discord client ID"`
	ClientSecret string   `env:"CLIENT_SECRET" long:"client-secret" required:"true" description:"Discord client secret"`
	Admins       []string `` /* 129-byte string literal not displayed */
}

ConfigDiscord are configurations specifically utilized for interacting with Discord.

type ConfigHTTP

type ConfigHTTP struct {
	BaseURL        string   `env:"BASE_URL"        long:"base-url"        default:"http://localhost:8080" description:"base url for the HTTP server"`
	BindAddr       string   `env:"BIND_ADDR"       long:"bind-addr"       default:":8080" required:"true" description:"ip:port pair to bind to"`
	TrustedProxies []string `` /* 193-byte string literal not displayed */
	ValidationKey  string   `` /* 128-byte string literal not displayed */
	EncryptionKey  string   `env:"ENCRYPTION_KEY"  long:"encryption-key"  required:"true" description:"key used to encrypt session cookies (32 bytes)"`
}

ConfigHTTP are configurations specifically utilized by the HTTP service.

type ConfigWorker

type ConfigWorker struct {
	// https://discord.com/developers/docs/topics/gateway#sharding
	// Note: Shard ID 0 will be the only one to receive DMs.
	ShardIDs           []uint        `` /* 126-byte string literal not displayed */
	NumShards          uint          `env:"NUM_SHARDS"           long:"num-shards" default:"1"            description:"number of total shards"`
	BotToken           string        `env:"BOT_TOKEN"            long:"bot-token"  required:"true"        description:"Discord bot token"`
	EventFlushInterval time.Duration `env:"EVENT_FLUSH_INTERVAL" long:"event-flush-interval" default:"5s" description:"how often to flush events to the database"`
}

type DiscordPermissions

type DiscordPermissions uint64

DiscordPermissions is used to convert Discord permission bits to Go bitwise-able values for comparison and validation. Discord docs: https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags

func (DiscordPermissions) Contains

func (b DiscordPermissions) Contains(bits DiscordPermissions) bool

Contains is used to check if the permission integer contains the bits specified.

func (*DiscordPermissions) MarshalJSON

func (b *DiscordPermissions) MarshalJSON() ([]byte, error)

func (*DiscordPermissions) UnmarshalJSON

func (b *DiscordPermissions) UnmarshalJSON(bytes []byte) error

type ErrUserBanned

type ErrUserBanned struct {
	User *ent.User
}

func (ErrUserBanned) Error

func (e ErrUserBanned) Error() string

type Flags

type Flags struct {
	HTTP          ConfigHTTP     `group:"HTTP Server options"    namespace:"http"     env-namespace:"HTTP"`
	Database      ConfigDatabase `group:"Database options"       namespace:"database" env-namespace:"DATABASE"`
	Discord       ConfigDiscord  `group:"Discord options"        namespace:"discord"  env-namespace:"DISCORD"`
	DefaultWorker ConfigWorker   `group:"Default worker options" namespace:"worker"   env-namespace:"WORKER"`
}

type UserGuildResponse

type UserGuildResponse struct {
	ID          string             `json:"id"`              // Guild id.
	Name        string             `json:"name"`            // Guild name (2-100 chars, excl. trailing/leading spaces).
	Owner       bool               `json:"owner"`           // True if the user is the owner of the guild
	Features    []string           `json:"features"`        // Enabled guild features.
	Icon        string             `json:"icon"`            // Icon hash.
	Permissions DiscordPermissions `json:"permissions_new"` // Permissions for the user (excludes overrides).
}
{
    "features": [
        "WELCOME_SCREEN_ENABLED", "NEWS", "COMMUNITY"
    ],
    "icon":"3a0892e2c181bd2fe877e6c4341d163e",
    "id":"679506910449500196",
    "name":"bytecord",
    "owner":true,
    "permissions":2.147483647e+09,
    "permissions_new":"8589934591"
}

https://discord.com/developers/docs/resources/guild#guild-object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL