utils

package
v0.0.0-...-f00225b Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: OSL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CategoryBot        = "Bot"
	CategoryFun        = "Fun"
	CategoryImage      = "Image"
	CategoryMusic      = "Music"
	CategoryModeration = "Moderation"
	CategoryOwner      = "Owner"
	CategoryUtils      = "Utils"
	CategoryVoice      = "Voice"
	CategoryWeb        = "Web"
)

Variables

View Source
var (
	RoleCheckFuncs = []func(*discordgo.Role, string) bool{

		func(r *discordgo.Role, resolvable string) bool {
			return r.ID == resolvable
		},

		func(r *discordgo.Role, resolvable string) bool {
			return r.Name == resolvable
		},

		func(r *discordgo.Role, resolvable string) bool {
			return strings.ToLower(r.Name) == strings.ToLower(resolvable)
		},

		func(r *discordgo.Role, resolvable string) bool {
			return strings.HasPrefix(strings.ToLower(r.Name), strings.ToLower(resolvable))
		},

		func(r *discordgo.Role, resolvable string) bool {
			return strings.Contains(strings.ToLower(r.Name), strings.ToLower(resolvable))
		},
	}

	MemberCheckFuncs = []func(*discordgo.Member, string) bool{

		func(r *discordgo.Member, resolvable string) bool {
			return r.User.ID == resolvable
		},

		func(r *discordgo.Member, resolvable string) bool {
			return r.User.Username == resolvable
		},

		func(r *discordgo.Member, resolvable string) bool {
			return strings.ToLower(r.User.Username) == strings.ToLower(resolvable)
		},

		func(r *discordgo.Member, resolvable string) bool {
			return strings.HasPrefix(strings.ToLower(r.User.Username), strings.ToLower(resolvable))
		},

		func(r *discordgo.Member, resolvable string) bool {
			return strings.Contains(strings.ToLower(r.User.Username), strings.ToLower(resolvable))
		},

		func(r *discordgo.Member, resolvable string) bool {
			return r.Nick == resolvable
		},

		func(r *discordgo.Member, resolvable string) bool {
			return r.Nick != "" && strings.ToLower(r.Nick) == strings.ToLower(resolvable)
		},

		func(r *discordgo.Member, resolvable string) bool {
			return r.Nick != "" && strings.HasPrefix(strings.ToLower(r.Nick), strings.ToLower(resolvable))
		},

		func(r *discordgo.Member, resolvable string) bool {
			return r.Nick != "" && strings.Contains(strings.ToLower(r.Nick), strings.ToLower(resolvable))
		},
	}

	ChannelCheckFuncs = []func(*discordgo.Channel, string) bool{

		func(r *discordgo.Channel, resolvable string) bool {
			return r.ID == resolvable
		},

		func(r *discordgo.Channel, resolvable string) bool {
			l := len(resolvable)
			return l > 3 && r.ID == resolvable[2:l-1]
		},

		func(r *discordgo.Channel, resolvable string) bool {
			return r.Name == resolvable
		},

		func(r *discordgo.Channel, resolvable string) bool {
			return strings.ToLower(r.Name) == strings.ToLower(resolvable)
		},

		func(r *discordgo.Channel, resolvable string) bool {
			return strings.HasPrefix(strings.ToLower(r.Name), strings.ToLower(resolvable))
		},

		func(r *discordgo.Channel, resolvable string) bool {
			return strings.Contains(strings.ToLower(r.Name), strings.ToLower(resolvable))
		},
	}
)
View Source
var (
	ErrInvalidDurationFormat = errors.New("invalid duration format")
)

Functions

func BoolPointer

func BoolPointer(b bool) *bool

func ConvertStringToActivityType

func ConvertStringToActivityType(in string) discordgo.ActivityType

func ErrorEmbed

func ErrorEmbed(ctx dgc.Ctx, err error) *discordgo.MessageEmbed

func ErrorHandler

func ErrorHandler(err error) error

func FetchMember

func FetchMember(s DataOutlet, guildID, resolvable string, condition ...func(*discordgo.Member) bool) (*discordgo.Member, error)

FetchMember tries to fetch a member on the specified guild by given resolvable and returns this member, when found. You can pass a condition function which ignores the result if this functions returns false on the given object. If no object was found, ErrNotFound is returned. If any other unexpected error occurs during fetching, this error is returned as well.

func FindNamedSubmatchMap

func FindNamedSubmatchMap(re *regexp.Regexp, s string) map[string]string

func GenerateEmbed

func GenerateEmbed(ctx dgc.Ctx, e discordgo.MessageEmbed) *discordgo.MessageEmbed

func GetAstralIdFromUser

func GetAstralIdFromUser(s *discordgo.Session, user string, db db.SupabaseMiddleware) (string, error)

func GetSortedMemberRoles

func GetSortedMemberRoles(s *discordgo.Session, guildID, memberID string, reversed bool, includeEveryone bool) ([]*discordgo.Role, error)

func GetUserFromAstralId

func GetUserFromAstralId(s *discordgo.Session, id string, db db.SupabaseMiddleware) (*discordgo.User, error)

func Int64Pointer

func Int64Pointer(i int64) *int64

func IntPointer

func IntPointer(i int) *int

func IsAdmin

func IsAdmin(g *discordgo.Guild, m *discordgo.Member) bool

IsAdmin returns true if one of the members roles has admin (0x8) permissions on the passed guild.

func NowAddPtr

func NowAddPtr(d time.Duration) time.Time

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

func SortRoles

func SortRoles(r []*discordgo.Role, reversed bool)

func StringInSlice

func StringInSlice(a string, list []string) bool

func WithCustomRatelimit

func WithCustomRatelimit(cmd *dgc.Command, ratelimit int64) *dgc.Command

Types

type Child

type Child struct {
	Kind string     `json:"kind"`
	Data RedditPost `json:"data"`
}

type DataOutlet

type DataOutlet interface {
	GuildRoles(guildID string) ([]*discordgo.Role, error)
	GuildMembers(guildID string, after string, limit int) (st []*discordgo.Member, err error)
	GuildChannels(guildID string) (st []*discordgo.Channel, err error)
}

type Gildings

type Gildings struct {
}

type IBlacklist

type IBlacklist struct {
	ID             int8        `json:"id"`
	CreatedAt      time.Time   `json:"created_at"`
	Moderator      string      `json:"moderator"`
	User           string      `json:"user"`
	DiscordID      string      `json:"discord_id"`
	Reason         string      `json:"reason"`
	Expires        bool        `json:"expires"`
	Expiry         time.Time   `json:"expiry"`
	Flags          interface{} `json:"flags"`
	FactorMatching []string    `json:"factor_matching"`
	Notes          string      `json:"notes"`
}

type IBot

type IBot struct {
	ID          *string       `json:"id,omitempty"`
	CreatedAt   *time.Time    `json:"created_at,omitempty"`
	Region      string        `json:"region" form:"region"`
	Owner       *string       `json:"owner,omitempty"`
	Workspace   *string       `json:"workspace,omitempty"`
	Settings    IBotSettings  `json:"settings" form:"settings"`
	Token       string        `json:"token" form:"token"`
	Commands    []IBotCommand `json:"commands" form:"commands"`
	Permissions IPermissions  `json:"permissions" form:"permissions"`
}

type IBotActivity

type IBotActivity struct {
	Name string `json:"name" form:"name"`
	Type string `json:"type" form:"type"`
}

type IBotAnalytics

type IBotAnalytics struct {
	ID        *int        `json:"id,omitempty"`
	Commands  interface{} `json:"commands"`
	Timestamp time.Time   `json:"timestamp"`
	Members   int         `json:"members"`
	Messages  int         `json:"messages"`
	Bot       *IBot       `json:"bot,omitempty"`
}

type IBotCommand

type IBotCommand struct {
	ID      string      `json:"id"`
	Options interface{} `json:"options"`
	Enabled bool        `json:"enabled"`
}

type IBotModule

type IBotModule[T any] struct {
	Enabled bool `json:"enabled"`
	Options T    `json:"options"`
}

type IBotModules

type IBotModules struct {
	Fun        IBotModule[any] `json:"fun"`
	Moderation IBotModule[struct {
		Logging struct {
			Enabled bool   `json:"enabled"`
			Channel string `json:"channel"`
		} `json:"logging"`
	}] `json:"moderation"`
}

type IBotSettings

type IBotSettings struct {
	Guild               string         `json:"guild" form:"guild"`
	Prefix              string         `json:"prefix" form:"prefix"`
	Status              string         `json:"status" form:"status"`
	Activities          []IBotActivity `json:"activities" form:"activities"`
	RandomizeActivities bool           `json:"randomizeActivities" form:"randomizeActivities"`
	ActivityInterval    int            `json:"activityInterval" form:"activityInterval"`
	CurrentActivity     int            `json:"currentActivity"`
	Modules             IBotModules    `json:"modules" form:"modules"`
}

type IDiscordApiUser

type IDiscordApiUser struct {
	ID            string  `json:"id"`
	Username      string  `json:"username"`
	Discriminator string  `json:"discriminator"`
	Avatar        *string `json:"avatar,omitempty"`
	Bot           *bool   `json:"bot,omitempty"`
	System        *bool   `json:"system,omitempty"`
	MFAEnabled    *bool   `json:"mfa_enabled,omitempty"`
	Banner        *string `json:"banner,omitempty"`
	AccentColor   *int    `json:"accent_color,omitempty"`
	Locale        *string `json:"locale,omitempty"`
	Verified      *bool   `json:"verified,omitempty"`
	Email         *string `json:"email,omitempty"`
	Flags         *int    `json:"flags,omitempty"`
	PremiumType   *int    `json:"premium_type,omitempty"`
	PublicFlags   *int    `json:"public_flags,omitempty"`
}

type IIdentityData

type IIdentityData struct {
	Iss           string `json:"iss"`
	Sub           string `json:"sub"`
	Name          string `json:"name"`
	Email         string `json:"email"`
	Picture       string `json:"picture"`
	FullName      string `json:"full_name"`
	AvatarURL     string `json:"avatar_url"`
	ProviderID    string `json:"provider_id"`
	EmailVerified bool   `json:"email_verified"`
}

type IIntegration

type IIntegration struct {
	ID               string             `json:"id"`
	CreatedAt        time.Time          `json:"created_at"`
	Name             string             `json:"name"`
	PrettyName       string             `json:"prettyName"`
	Icon             string             `json:"icon"`
	IsIconSimpleIcon bool               `json:"isIconSimpleIcon"`
	Website          string             `json:"website"`
	Enabled          bool               `json:"enabled"`
	Description      string             `json:"description"`
	Schema           IIntegrationSchema `json:"schema"`
}

type IIntegrationSchema

type IIntegrationSchema struct {
	Type       string     `json:"type"`
	Title      string     `json:"title"`
	Properties OrderedMap `json:"properties"`
}

type IIntegrationSchemaInput

type IIntegrationSchemaInput struct {
	Type  string `json:"type"`
	Title string `json:"title"`
}

type IPermissions

type IPermissions struct {
	DefaultAdminRules []string            `json:"defaultAdminRules"`
	DefaultUserRules  []string            `json:"defaultUserRules"`
	Users             map[string][]string `json:"users"`
}

type IPlan

type IPlan struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	PriceMonthly string `json:"priceMonthly"`
	PriceYearly  string `json:"priceYearly"`
	Limit        string `json:"limit"`
	Enabled      bool   `json:"enabled"`
}

type IProfile

type IProfile struct {
	ID               string        `json:"id"`
	Email            string        `json:"email"`
	PreferredName    string        `json:"preferred_name"`
	IdentityData     IIdentityData `json:"identity_data"`
	Access           string        `json:"access"`
	DiscordID        string        `json:"discord_id"`
	RobloxID         interface{}   `json:"roblox_id"`
	StripeCustomerID string        `json:"stripe_customer_id"`
	CreatedAt        string        `json:"created_at"`
	Location         string        `json:"location"`
	Language         string        `json:"language"`
	Pronouns         []string      `json:"pronouns"`
	Hireable         bool          `json:"hireable"`
	About            string        `json:"about"`
	Strengths        []string      `json:"strengths"`
	Weaknesses       []string      `json:"weaknesses"`
	Banner           string        `json:"banner"`
	Verified         bool          `json:"verified"`
	Public           bool          `json:"public"`
	Workspaces       []IWorkspace  `json:"workspaces"`
}

type IProvider

type IProvider struct {
	ID                   *string                `json:"id,omitempty"`
	CreatedAt            time.Time              `json:"created_at"`
	User                 string                 `json:"user"`
	Type                 string                 `json:"type"`
	ProviderID           string                 `json:"provider_id"`
	ProviderAccessToken  string                 `json:"provider_access_token"`
	ProviderRefreshToken string                 `json:"provider_refresh_token"`
	ProviderData         map[string]interface{} `json:"provider_data"`
	ProviderExpiresAt    *time.Time             `json:"provider_expires_at,omitempty"`
	ProviderAvatarUrl    *string                `json:"provider_avatar_url,omitempty"`
	ProviderEmail        *string                `json:"provider_email,omitempty"`
}

type IRegion

type IRegion struct {
	ID         string  `json:"id"`
	Flag       string  `json:"flag"`
	IP         string  `json:"ip"`
	City       string  `json:"city"`
	Country    string  `json:"country"`
	Region     string  `json:"region"`
	PrettyName string  `json:"prettyName"`
	Lat        float64 `json:"lat"`
	Long       float64 `json:"long"`
	MaxBots    int     `json:"maxBots"`
	Status     string  `json:"status"`

	Bots int `json:"bots"`
}

type IRobloxIntegration

type IRobloxIntegration struct {
	GroupId           string                              `json:"groupId" form:"groupId"`
	Token             string                              `json:"token" form:"token"`
	MemberCounter     IRobloxIntegrationMemberCounter     `json:"memberCounter" form:"memberCounter"`
	ShoutProxy        IRobloxIntegrationShoutProxy        `json:"shoutProxy" form:"shoutProxy"`
	BadActorDetection IRobloxIntegrationBadActorDetection `json:"badActorDetection" form:"badActorDetection"`
	WallFilter        IRobloxIntegrationWallFilter        `json:"wallFilter" form:"wallFilter"`
}

type IRobloxIntegrationBadActorDetection

type IRobloxIntegrationBadActorDetection struct {
	Enabled bool `json:"enabled" form:"enabled"`
	Factors struct {
		BannedGroups    string `json:"bannedGroups" form:"bannedGroups"`
		SketchyUsername bool   `json:"sketchyUsername" form:"sketchyUsername"`
		NoDescription   bool   `json:"noDescription" form:"noDescription"`
	}
}

type IRobloxIntegrationMemberCounter

type IRobloxIntegrationMemberCounter struct {
	Enabled bool   `json:"enabled" form:"enabled"`
	Message string `json:"message" form:"message"`
	Webhook string `json:"webhook" form:"webhook"`
	GroupId string `json:"groupId" form:"groupId"`
}

type IRobloxIntegrationShoutProxy

type IRobloxIntegrationShoutProxy struct {
	Enabled bool   `json:"enabled" form:"enabled"`
	Webhook string `json:"webhook" form:"webhook"`
	GroupId string `json:"groupId" form:"groupId"`
}

type IRobloxIntegrationWallFilter

type IRobloxIntegrationWallFilter struct {
	Enabled       bool   `json:"enabled" form:"enabled"`
	BannedPhrases string `json:"bannedPhrases" form:"bannedPhrases"`
}

type IRobloxSchema

type IRobloxSchema struct {
	GroupId           orderedjson.Map `json:"groupId"`
	Token             orderedjson.Map `json:"token"`
	MemberCounter     orderedjson.Map `json:"member_counter"`
	ShoutProxy        orderedjson.Map `json:"shout_proxy"`
	BadActorDetection orderedjson.Map `json:"bad_actor_detection"`
	WallFilter        orderedjson.Map `json:"wall_filter"`
	Submit            orderedjson.Map `json:"submit"`
}

type IRobloxSchemaBadActorDetection

type IRobloxSchemaBadActorDetection struct {
	Enabled orderedjson.Map `json:"enabled"`
	Factors orderedjson.Map `json:"factors"`
}

type IRobloxSchemaFactors

type IRobloxSchemaFactors struct {
	BannedGroups    orderedjson.Map `json:"banned_groups"`
	SketchyUsername orderedjson.Map `json:"sketchyUsername"`
	NoDescription   orderedjson.Map `json:"noDescription"`
}

type IRobloxSchemaMemberCounter

type IRobloxSchemaMemberCounter struct {
	Enabled orderedjson.Map `json:"enabled"`
	Message orderedjson.Map `json:"message"`
	Webhook orderedjson.Map `json:"webhook"`
	GroupId orderedjson.Map `json:"groupId"`
}

type IRobloxSchemaShoutProxy

type IRobloxSchemaShoutProxy struct {
	Enabled orderedjson.Map `json:"enabled"`
	Webhook orderedjson.Map `json:"webhook"`
	GroupId orderedjson.Map `json:"groupId"`
}

type IRobloxSchemaWallFilter

type IRobloxSchemaWallFilter struct {
	BannedPhrases orderedjson.Map `json:"bannedPhrases"`
}

type IStatistic

type IStatistic struct {
	ID        int     `json:"id"`
	Key       string  `json:"key"`
	Value     float32 `json:"value"`
	UpdatedAt string  `json:"updated_at"`
}

type ITeamMember

type ITeamMember struct {
	ID        int             `json:"id"`
	CreatedAt string          `json:"created_at"`
	User      ITeamMemberUser `json:"user"`
	Name      string          `json:"name"`
	Pronouns  string          `json:"pronouns"`
	Location  string          `json:"location"`
	About     string          `json:"about"`
	Role      string          `json:"role"`
}

type ITeamMemberUser

type ITeamMemberUser struct {
	IdentityData IIdentityData `json:"identity_data"`
}

type IWorkspace

type IWorkspace struct {
	ID           *string     `json:"id,omitempty"`
	CreatedAt    *string     `json:"created_at,omitempty"`
	Owner        *string     `json:"owner,omitempty"`
	Members      *[]string   `json:"members,omitempty"`
	GroupID      *string     `json:"group_id,omitempty"`
	Name         string      `json:"name" form:"name"`
	Settings     interface{} `json:"settings"`
	Plan         int64       `json:"plan" form:"plan"`
	Visibility   string      `json:"visibility" form:"visibility"`
	Integrations interface{} `json:"integrations"`
	Pending      bool        `json:"pending"`
}

type IWorkspaceIntegration

type IWorkspaceIntegration struct {
	ID          int         `json:"id"`
	CreatedAt   time.Time   `json:"created_at"`
	Integration string      `json:"integration"`
	Settings    interface{} `json:"settings"`
	Workspace   string      `json:"workspace"`
	Enabled     bool        `json:"enabled"`
}

type IWorkspaceMember

type IWorkspaceMember struct {
	ID        string     `json:"id"`
	CreatedAt string     `json:"created_at"`
	Profile   IProfile   `json:"profile"`
	Workspace IWorkspace `json:"workspace"`
	Role      string     `json:"role"`
	Pending   bool       `json:"pending"`
	InvitedBy string     `json:"invited_by"`
}

type IWorkspaceMemberWithoutProfile

type IWorkspaceMemberWithoutProfile struct {
	ID        string `json:"id"`
	CreatedAt string `json:"created_at"`
	Workspace any    `json:"workspace"`
	Role      string `json:"role"`
	Pending   bool   `json:"pending"`
	InvitedBy string `json:"invited_by"`
}

type Image

type Image struct {
	Source      Source   `json:"source"`
	Resolutions []Source `json:"resolutions"`
	Variants    Gildings `json:"variants"`
	ID          string   `json:"id"`
}

type MemoryUsage

type MemoryUsage struct {
	Allocated      string
	AllocatedTotal string
	Sys            string
}

func GetMemoryUsage

func GetMemoryUsage() MemoryUsage

type OrderedMap

type OrderedMap struct {
	Order []string
	Map   map[string]string
}

func (OrderedMap) MarshalJSON

func (om OrderedMap) MarshalJSON() ([]byte, error)

func (*OrderedMap) UnmarshalJSON

func (om *OrderedMap) UnmarshalJSON(b []byte) error

type Preview

type Preview struct {
	Images  []Image `json:"images"`
	Enabled bool    `json:"enabled"`
}

type RealtimeOptions

type RealtimeOptions struct {
	Endpoint string
	Key      string
	Table    string

	OnInsert func(m realtimego.Message)
	OnDelete func(m realtimego.Message)
	OnUpdate func(m realtimego.Message)
}

func (RealtimeOptions) SetupRealtime

func (opts RealtimeOptions) SetupRealtime()

type RealtimePayload

type RealtimePayload[T any] struct {
	Columns         []map[string]string `json:"columns"`
	CommitTimestamp time.Time           `json:"commit_timestamp"`
	Errors          *any                `json:"errors,omitempty"`
	OldRecord       T                   `json:"old_record"`
	Record          T                   `json:"record"`
	Schema          string              `json:"schema"`
	Table           string              `json:"table"`
	Type            string              `json:"type"`
}

type RedditPost

type RedditPost struct {
	ApprovedAtUTC              interface{}   `json:"approved_at_utc"`
	Subreddit                  string        `json:"subreddit"`
	Selftext                   string        `json:"selftext"`
	UserReports                []interface{} `json:"user_reports"`
	Saved                      bool          `json:"saved"`
	ModReasonTitle             interface{}   `json:"mod_reason_title"`
	Gilded                     int64         `json:"gilded"`
	Clicked                    bool          `json:"clicked"`
	Title                      string        `json:"title"`
	LinkFlairRichtext          []interface{} `json:"link_flair_richtext"`
	SubredditNamePrefixed      string        `json:"subreddit_name_prefixed"`
	Hidden                     bool          `json:"hidden"`
	Pwls                       int64         `json:"pwls"`
	LinkFlairCSSClass          interface{}   `json:"link_flair_css_class"`
	Downs                      int64         `json:"downs"`
	ThumbnailHeight            int64         `json:"thumbnail_height"`
	TopAwardedType             interface{}   `json:"top_awarded_type"`
	ParentWhitelistStatus      string        `json:"parent_whitelist_status"`
	HideScore                  bool          `json:"hide_score"`
	Name                       string        `json:"name"`
	Quarantine                 bool          `json:"quarantine"`
	LinkFlairTextColor         string        `json:"link_flair_text_color"`
	UpvoteRatio                int64         `json:"upvote_ratio"`
	AuthorFlairBackgroundColor interface{}   `json:"author_flair_background_color"`
	SubredditType              string        `json:"subreddit_type"`
	UPS                        int64         `json:"ups"`
	TotalAwardsReceived        int64         `json:"total_awards_received"`
	MediaEmbed                 Gildings      `json:"media_embed"`
	ThumbnailWidth             int64         `json:"thumbnail_width"`
	AuthorFlairTemplateID      interface{}   `json:"author_flair_template_id"`
	IsOriginalContent          bool          `json:"is_original_content"`
	AuthorFullname             string        `json:"author_fullname"`
	SecureMedia                interface{}   `json:"secure_media"`
	IsRedditMediaDomain        bool          `json:"is_reddit_media_domain"`
	IsMeta                     bool          `json:"is_meta"`
	Category                   interface{}   `json:"category"`
	SecureMediaEmbed           Gildings      `json:"secure_media_embed"`
	LinkFlairText              interface{}   `json:"link_flair_text"`
	CanModPost                 bool          `json:"can_mod_post"`
	Score                      int64         `json:"score"`
	ApprovedBy                 interface{}   `json:"approved_by"`
	IsCreatedFromAdsUI         bool          `json:"is_created_from_ads_ui"`
	AuthorPremium              bool          `json:"author_premium"`
	Thumbnail                  string        `json:"thumbnail"`
	Edited                     bool          `json:"edited"`
	AuthorFlairCSSClass        interface{}   `json:"author_flair_css_class"`
	AuthorFlairRichtext        []interface{} `json:"author_flair_richtext"`
	Gildings                   Gildings      `json:"gildings"`
	PostHint                   string        `json:"post_hint"`
	ContentCategories          interface{}   `json:"content_categories"`
	IsSelf                     bool          `json:"is_self"`
	ModNote                    interface{}   `json:"mod_note"`
	Created                    int64         `json:"created"`
	LinkFlairType              string        `json:"link_flair_type"`
	Wls                        int64         `json:"wls"`
	RemovedByCategory          interface{}   `json:"removed_by_category"`
	BannedBy                   interface{}   `json:"banned_by"`
	AuthorFlairType            string        `json:"author_flair_type"`
	Domain                     string        `json:"domain"`
	AllowLiveComments          bool          `json:"allow_live_comments"`
	SelftextHTML               interface{}   `json:"selftext_html"`
	Likes                      interface{}   `json:"likes"`
	SuggestedSort              interface{}   `json:"suggested_sort"`
	BannedAtUTC                interface{}   `json:"banned_at_utc"`
	URLOverriddenByDest        string        `json:"url_overridden_by_dest"`
	ViewCount                  interface{}   `json:"view_count"`
	Archived                   bool          `json:"archived"`
	NoFollow                   bool          `json:"no_follow"`
	IsCrosspostable            bool          `json:"is_crosspostable"`
	Pinned                     bool          `json:"pinned"`
	Over18                     bool          `json:"over_18"`
	Preview                    Preview       `json:"preview"`
	AllAwardings               []interface{} `json:"all_awardings"`
	Awarders                   []interface{} `json:"awarders"`
	MediaOnly                  bool          `json:"media_only"`
	CanGild                    bool          `json:"can_gild"`
	Spoiler                    bool          `json:"spoiler"`
	Locked                     bool          `json:"locked"`
	AuthorFlairText            interface{}   `json:"author_flair_text"`
	TreatmentTags              []interface{} `json:"treatment_tags"`
	Visited                    bool          `json:"visited"`
	RemovedBy                  interface{}   `json:"removed_by"`
	NumReports                 interface{}   `json:"num_reports"`
	Distinguished              interface{}   `json:"distinguished"`
	SubredditID                string        `json:"subreddit_id"`
	AuthorIsBlocked            bool          `json:"author_is_blocked"`
	ModReasonBy                interface{}   `json:"mod_reason_by"`
	RemovalReason              interface{}   `json:"removal_reason"`
	LinkFlairBackgroundColor   string        `json:"link_flair_background_color"`
	ID                         string        `json:"id"`
	IsRobotIndexable           bool          `json:"is_robot_indexable"`
	NumDuplicates              int64         `json:"num_duplicates"`
	ReportReasons              interface{}   `json:"report_reasons"`
	Author                     string        `json:"author"`
	DiscussionType             interface{}   `json:"discussion_type"`
	NumComments                int64         `json:"num_comments"`
	SendReplies                bool          `json:"send_replies"`
	Media                      interface{}   `json:"media"`
	ContestMode                bool          `json:"contest_mode"`
	AuthorPatreonFlair         bool          `json:"author_patreon_flair"`
	AuthorFlairTextColor       interface{}   `json:"author_flair_text_color"`
	Permalink                  string        `json:"permalink"`
	WhitelistStatus            string        `json:"whitelist_status"`
	Stickied                   bool          `json:"stickied"`
	URL                        string        `json:"url"`
	SubredditSubscribers       int64         `json:"subreddit_subscribers"`
	CreatedUTC                 int64         `json:"created_utc"`
	NumCrossposts              int64         `json:"num_crossposts"`
	ModReports                 []interface{} `json:"mod_reports"`
	IsVideo                    bool          `json:"is_video"`
}

type RedditPostData

type RedditPostData struct {
	After     interface{} `json:"after"`
	Dist      *int64      `json:"dist"`
	Modhash   string      `json:"modhash"`
	GeoFilter string      `json:"geo_filter"`
	Children  []Child     `json:"children"`
	Before    interface{} `json:"before"`
}

type RedditResponse

type RedditResponse []RedditResponseElement

type RedditResponseElement

type RedditResponseElement struct {
	Kind string         `json:"kind"`
	Data RedditPostData `json:"data"`
}

type Response

type Response[T any] struct {
	Result T      `json:"result"`
	Error  string `json:"error"`
	Code   int    `json:"code"`
}

type Source

type Source struct {
	URL    string `json:"url"`
	Width  int64  `json:"width"`
	Height int64  `json:"height"`
}

type Subreddit

type Subreddit struct {
	Name string
}

func (*Subreddit) RandomHot

func (s *Subreddit) RandomHot() (*RedditPost, error)

Jump to

Keyboard shortcuts

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