discord

package
v0.162.15 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MPL-2.0, MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MaxImportFileSizeBytes = 52428800
View Source
const MaxTaskErrorItemsCount = 3

Variables

View Source
var (
	ErrNoChannelData    = errors.New("No channels to import messages from")
	ErrNoMessageData    = errors.New("No messages to import")
	ErrMarshalMessage   = errors.New("Couldn't marshal discord message")
	ErrImportFileTooBig = fmt.Errorf("File is too big (max. %d MB)", MaxImportFileSizeBytes/1024/1024)
)

Functions

func DownloadAsset added in v0.114.1

func DownloadAsset(url string) ([]byte, string, error)

func DownloadAvatarAsset added in v0.114.1

func DownloadAvatarAsset(url string) ([]byte, error)

Types

type AssetCounter added in v0.114.1

type AssetCounter struct {
	// contains filtered or unexported fields
}

func (*AssetCounter) Increase added in v0.114.1

func (c *AssetCounter) Increase()

func (*AssetCounter) Value added in v0.114.1

func (c *AssetCounter) Value() uint64

type Category

type Category struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Channel

type Channel struct {
	ID           string `json:"id"`
	CategoryName string `json:"category"`
	CategoryID   string `json:"categoryId"`
	Name         string `json:"name"`
	Description  string `json:"topic"`
	FilePath     string `json:"filePath"`
}

type ErrorCodeType added in v0.114.1

type ErrorCodeType uint
const (
	NoErrorType ErrorCodeType = iota + 1
	WarningType
	ErrorType
)

type ExportedData

type ExportedData struct {
	Channel      Channel                    `json:"channel"`
	Messages     []*protobuf.DiscordMessage `json:"messages"`
	MessageCount int                        `json:"messageCount"`
}

type ExtractedData

type ExtractedData struct {
	Categories             map[string]*Category
	ExportedData           []*ExportedData
	OldestMessageTimestamp int
	MessageCount           int
}

type ImportError

type ImportError struct {
	// This code is used to distinguish between errors
	// that are considered "criticial" and those that are not.
	//
	// Critical errors are the ones that prevent the imported community
	// from functioning properly. For example, if the creation of the community
	// or its categories and channels fails, this is a critical error.
	//
	// Non-critical errors are the ones that would not prevent the imported
	// community from functioning. For example, if the channel data to be imported
	// has no messages, or is not parsable.
	Code     ErrorCodeType `json:"code"`
	Message  string        `json:"message"`
	TaskInfo string        `json:"taskInfo"`
}

func Error

func Error(message string) *ImportError

func Warning

func Warning(message string) *ImportError

func (ImportError) Error

func (d ImportError) Error() string

type ImportProgress added in v0.114.1

type ImportProgress struct {
	CommunityID     string                          `json:"communityId,omitempty"`
	CommunityName   string                          `json:"communityName"`
	CommunityImages map[string]images.IdentityImage `json:"communityImages"`
	Tasks           []*ImportTaskProgress           `json:"tasks"`
	Progress        float32                         `json:"progress"`
	ErrorsCount     uint                            `json:"errorsCount"`
	WarningsCount   uint                            `json:"warningsCount"`
	Stopped         bool                            `json:"stopped"`
	TotalChunkCount int                             `json:"totalChunksCount,omitempty"`
	CurrentChunk    int                             `json:"currentChunk,omitempty"`
	// contains filtered or unexported fields
}

func (*ImportProgress) AddTaskError added in v0.114.1

func (progress *ImportProgress) AddTaskError(task ImportTask, err *ImportError)

func (*ImportProgress) Init added in v0.114.1

func (progress *ImportProgress) Init(totalChunkCount int, tasks []ImportTask)

func (*ImportProgress) Stop added in v0.114.1

func (progress *ImportProgress) Stop()

func (*ImportProgress) StopTask added in v0.114.1

func (progress *ImportProgress) StopTask(task ImportTask)

func (*ImportProgress) UpdateTaskProgress added in v0.114.1

func (progress *ImportProgress) UpdateTaskProgress(task ImportTask, value float32)

func (*ImportProgress) UpdateTaskState added in v0.114.1

func (progress *ImportProgress) UpdateTaskState(task ImportTask, state ImportTaskState)

type ImportTask added in v0.114.1

type ImportTask uint
const (
	CommunityCreationTask ImportTask = iota + 1
	ChannelsCreationTask
	ImportMessagesTask
	DownloadAssetsTask
	InitCommunityTask
)

func (ImportTask) String added in v0.114.1

func (t ImportTask) String() string

type ImportTaskProgress added in v0.114.1

type ImportTaskProgress struct {
	Type          string         `json:"type"`
	Progress      float32        `json:"progress"`
	Errors        []*ImportError `json:"errors"`
	Stopped       bool           `json:"stopped"`
	ErrorsCount   uint           `json:"errorsCount"`
	WarningsCount uint           `json:"warningsCount"`
	State         string         `json:"state"`
}

type ImportTaskState added in v0.114.1

type ImportTaskState uint
const (
	TaskStateInitialized ImportTaskState = iota
	TaskStateSaving
)

func (ImportTaskState) String added in v0.114.1

func (t ImportTaskState) String() string

type ImportTasks added in v0.114.1

type ImportTasks map[ImportTask]*ImportTaskProgress

type MessageType

type MessageType string
const (
	MessageTypeDefault       MessageType = "Default"
	MessageTypeReply         MessageType = "Reply"
	MessageTypeChannelPinned MessageType = "ChannelPinnedMessage"
)

Jump to

Keyboard shortcuts

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