Documentation
¶
Index ¶
- Constants
- Variables
- func AcquireSession(ctx context.Context, sub *subway.Subway, managerName string) (session *discord.Session, err error)
- func AddManagerNameToContext(ctx context.Context, v string) context.Context
- func AddMembershipToServer(ctx context.Context, logger zerolog.Logger, queries *database.Queries, ...) (newMembership database.UpdateUserMembershipParams, err error)
- func AddPoolToContext(ctx context.Context, v *pgxpool.Pool) context.Context
- func AddQueriesToContext(ctx context.Context, v *database.Queries) context.Context
- func AssertLength(name string, expectedLength int, arguments ...interface{}) (err error)
- func CheckGuildMemberships(memberships []*database.GetUserMembershipsByGuildIDRow) (hasWelcomerPro bool, hasCustomBackgrounds bool)
- func CreateMembershipForUser(ctx context.Context, queries *database.Queries, userID discord.Snowflake, ...) error
- func CreateTransactionForUser(ctx context.Context, queries *database.Queries, userID discord.Snowflake, ...) (*database.UserTransactions, error)
- func EnsureGuild(ctx context.Context, queries *database.Queries, guildID discord.Snowflake) error
- func EscapeStringForJSON(value string) string
- func FilterAssignableRoles(ctx context.Context, sandwichClient pb.SandwichClient, logger zerolog.Logger, ...) (out []discord.Snowflake, err error)
- func FormatString(funcs map[string]govaluate.ExpressionFunction, vars map[string]interface{}, ...) (string, error)
- func GatherFunctions() (funcs map[string]govaluate.ExpressionFunction)
- func GatherVariables(eventCtx *sandwich.EventContext, member discord.GuildMember, ...) (vars map[string]interface{})
- func GetGuildMemberDisplayName(member discord.GuildMember) string
- func GetManagerNameFromContext(ctx context.Context) string
- func GetPoolFromContext(ctx context.Context) *pgxpool.Pool
- func GetQueriesFromContext(ctx context.Context) *database.Queries
- func GetUserAvatar(user *discord.User) string
- func GetUserDisplayName(user *discord.User) string
- func IncludeBorderwallVerifyButton(messageParams discord.MessageParams, borderwallLink string) discord.MessageParams
- func IncludeScamsButton(messageParams discord.MessageParams) discord.MessageParams
- func IncludeSentByButton(messageParams discord.MessageParams, guildName string) discord.MessageParams
- func IsCustomBackgroundsMembership(membershipType database.MembershipType) bool
- func IsWelcomerProMembership(membershipType database.MembershipType) bool
- func MarshalTimeRolesJSON(roles []GuildSettingsTimeRolesRole) (rolesJSON []byte)
- func MemberHasElevation(discordGuild discord.Guild, member discord.GuildMember) bool
- func OnPatreonActive(ctx context.Context, logger zerolog.Logger, queries *database.Queries, ...) error
- func OnPatreonLinked(ctx context.Context, logger zerolog.Logger, queries *database.Queries, ...) error
- func OnPatreonNoLongerPledging(ctx context.Context, logger zerolog.Logger, queries *database.Queries, ...) error
- func OnPatreonTierChanged(ctx context.Context, logger zerolog.Logger, queries *database.Queries, ...) error
- func OnPatreonTierChanged_Fallback(ctx context.Context, logger zerolog.Logger, queries *database.Queries, ...) error
- func OnPatreonUnlinked(ctx context.Context, logger zerolog.Logger, queries *database.Queries, ...) error
- func RemoveMembershipFromServer(ctx context.Context, logger zerolog.Logger, queries *database.Queries, ...) (newMembership database.UpdateUserMembershipParams, err error)
- func RequireGuild(interaction discord.Interaction, handler BasicInteractionHandler) (*discord.InteractionResponse, error)
- func RequireGuildElevation(sub *subway.Subway, interaction discord.Interaction, ...) (*discord.InteractionResponse, error)
- type Attributes
- type BasicInteractionHandler
- type Currency
- type CustomEventInvokeBorderwallCompletionStructure
- type CustomEventInvokeBorderwallStructure
- type CustomEventInvokeLeaverStructure
- type CustomEventInvokeTempChannelsRemoveStructure
- type CustomEventInvokeTempChannelsStructure
- type CustomEventInvokeWelcomerStructure
- type GetPatreonMembersResponse
- type GuildSettingsTimeRolesRole
- type LastChargeStatus
- type OnInvokeBorderwallCompletionFuncType
- type OnInvokeBorderwallFuncType
- type OnInvokeLeaverFuncType
- type OnInvokeTempChannelsFuncType
- type OnInvokeTempChannelsRemoveFuncType
- type OnInvokeWelcomerFuncType
- type PatreonMember
- type PatreonTier
- type PatreonUser
- type PatreonUserOuter
- type PatreonUser_Attributes
- type PatreonUser_Discord
- type PatreonUser_SocialConnections
- type PatronSocialConnections
- type PatronStatus
- type PricingSKU
- type Relationships
- type SKUName
- type StubGuild
- type StubInvite
- type StubTime
- type StubUser
- type WelcomerInteractionsContextKey
Constants ¶
View Source
const ( EmojiCheck = "<:check:1196902761627914402>" EmojiCross = "<:cross:1196902764048031744>" EmojiNeutral = "<:neutral:1196903241959620730>" EmojiRock = "<:rock:732274836038221855>" )
View Source
const ( CustomEventInvokeWelcomer = "WELCOMER_INVOKE_WELCOMER" CustomEventInvokeLeaver = "WELCOMER_INVOKE_LEAVER" CustomEventInvokeTempChannels = "WELCOMER_INVOKE_TEMPCHANNELS" CustomEventInvokeTempChannelsRemove = "WELCOMER_INVOKE_TEMPCHANNELS_REMOVE" CustomEventInvokeBorderwall = "WELCOMER_INVOKE_BORDERWALL" CustomEventInvokeBorderwallCompletion = "WELCOMER_INVOKE_BORDERWALL_COMPLETION" )
View Source
const ( PatreonBase = "https://www.patreon.com/api/oauth2/v2/" CampaignID = "1150593" )
Variables ¶
View Source
var ( EmojiMessageBadge = discord.Emoji{ID: 987044175943970867, Name: "messagebadge"} EmojiShieldAlert = discord.Emoji{ID: 987044177160331322, Name: "shieldalert"} EmojiCheckMark = discord.Emoji{ID: 586907765662941185, Name: "checkboxmarkedoutline"} SupportInvite = "https://discord.gg/kQJz33ExK2" WebsiteURL = "https://" + os.Getenv("DOMAIN") // https://welcomer.gg )
View Source
var ( ErrMembershipAlreadyInUse = errors.New("membership is already in use") ErrMembershipInvalid = errors.New("membership is invalid") ErrMembershipExpired = errors.New("membership has expired") ErrMembershipNotInUse = errors.New("membership is not in use") ErrUnhandledMembership = errors.New("membership type is not handled") ErrTransactionNotComplete = errors.New("transaction not completed") )
View Source
var CountryMapping = map[string]Currency{ "IN": CurrencyINR, }
View Source
var GlobalCurrencies = []Currency{CurrencyEUR, CurrencyGBP, CurrencyUSD}
View Source
var SKUPricing = map[SKUName]PricingSKU{ SKUCustomBackgrounds: { ID: SKUCustomBackgrounds, Name: "Custom Backgrounds", Description: "One-time purchase to unlock custom welcome backgrounds for your server.", MembershipType: database.MembershipTypeCustomBackgrounds, SoftDescriptor: "Backgrounds", MonthCount: -1, Costs: map[Currency]string{ CurrencyEUR: "12.00", CurrencyGBP: "10.00", CurrencyUSD: "12.00", CurrencyINR: "300", }, }, SKUWelcomerPro: { ID: SKUWelcomerPro, Name: "Welcomer Pro", Description: "Unlock all Welcomer Pro features for your server.", MembershipType: database.MembershipTypeWelcomerPro, SoftDescriptor: "Pro", MonthCount: 1, Costs: map[Currency]string{ CurrencyEUR: "8.00", CurrencyGBP: "7.00", CurrencyUSD: "8.00", CurrencyINR: "300", }, }, SKUWelcomerProBiAnnual: { ID: SKUWelcomerProBiAnnual, Name: "Welcomer Pro", Description: "Unlock all Welcomer Pro features for your server.", MembershipType: database.MembershipTypeWelcomerPro, SoftDescriptor: "Pro", MonthCount: 6, Costs: map[Currency]string{ CurrencyEUR: "40.00", CurrencyGBP: "35.00", CurrencyUSD: "40.00", CurrencyINR: "1500", }, }, SKUWelcomerProAnnual: { ID: SKUWelcomerProAnnual, Name: "Welcomer Pro", Description: "Unlock all Welcomer Pro features for your server.", MembershipType: database.MembershipTypeWelcomerPro, SoftDescriptor: "Pro", MonthCount: 12, Costs: map[Currency]string{ CurrencyEUR: "80.00", CurrencyGBP: "70.00", CurrencyUSD: "80.00", CurrencyINR: "3000", }, }, }
Functions ¶
func AcquireSession ¶
func AddManagerNameToContext ¶
ManagerName context handler.
func AddMembershipToServer ¶
func AddPoolToContext ¶
Arguments context handler.
func AddQueriesToContext ¶
Queries context handler.
func AssertLength ¶
func CheckGuildMemberships ¶
func CheckGuildMemberships(memberships []*database.GetUserMembershipsByGuildIDRow) (hasWelcomerPro bool, hasCustomBackgrounds bool)
func CreateMembershipForUser ¶
func EnsureGuild ¶
EnsureGuild will create or update a guild entry. This requires RequireMutualGuild to be called.
func EscapeStringForJSON ¶
EscapeStringForJSON escapes a string for JSON.
func FilterAssignableRoles ¶
func FormatString ¶
func GatherFunctions ¶
func GatherFunctions() (funcs map[string]govaluate.ExpressionFunction)
func GatherVariables ¶
func GatherVariables(eventCtx *sandwich.EventContext, member discord.GuildMember, guild discord.Guild, invite *discord.Invite, extraValues map[string]interface{}) (vars map[string]interface{})
func GetGuildMemberDisplayName ¶
func GetGuildMemberDisplayName(member discord.GuildMember) string
func GetUserAvatar ¶
func GetUserDisplayName ¶
func IncludeBorderwallVerifyButton ¶
func IncludeBorderwallVerifyButton(messageParams discord.MessageParams, borderwallLink string) discord.MessageParams
func IncludeScamsButton ¶
func IncludeScamsButton(messageParams discord.MessageParams) discord.MessageParams
func IncludeSentByButton ¶
func IncludeSentByButton(messageParams discord.MessageParams, guildName string) discord.MessageParams
func IsCustomBackgroundsMembership ¶
func IsCustomBackgroundsMembership(membershipType database.MembershipType) bool
func IsWelcomerProMembership ¶
func IsWelcomerProMembership(membershipType database.MembershipType) bool
func MarshalTimeRolesJSON ¶
func MarshalTimeRolesJSON(roles []GuildSettingsTimeRolesRole) (rolesJSON []byte)
func MemberHasElevation ¶
func MemberHasElevation(discordGuild discord.Guild, member discord.GuildMember) bool
func OnPatreonActive ¶
func OnPatreonActive(ctx context.Context, logger zerolog.Logger, queries *database.Queries, patreonUser database.PatreonUsers, patreonMember PatreonMember) error
Triggered when a patron is still pledging.
func OnPatreonLinked ¶
func OnPatreonLinked(ctx context.Context, logger zerolog.Logger, queries *database.Queries, patreonUser PatreonUser, automatic bool) error
Triggers when a patreon account has been linked.
func OnPatreonNoLongerPledging ¶
func OnPatreonNoLongerPledging(ctx context.Context, logger zerolog.Logger, queries *database.Queries, patreonUser database.PatreonUsers, patreonMember PatreonMember) error
Triggers when a patron is no longer pledging
func OnPatreonTierChanged ¶
func OnPatreonTierChanged(ctx context.Context, logger zerolog.Logger, queries *database.Queries, beforePatreonUser *database.PatreonUsers, patreonUser database.CreateOrUpdatePatreonUserParams) error
Triggers when a patreon tier has changed.
func OnPatreonTierChanged_Fallback ¶
func OnPatreonTierChanged_Fallback(ctx context.Context, logger zerolog.Logger, queries *database.Queries, beforePatreonUser *database.PatreonUsers, patreonUser database.CreateOrUpdatePatreonUserParams, e error) error
Triggers when a patreon tier has changed. Ran if OnPatreonTierChange failed to run.
func OnPatreonUnlinked ¶
func OnPatreonUnlinked(ctx context.Context, logger zerolog.Logger, queries *database.Queries, patreonUser *database.PatreonUsers) error
Triggers when a patreon account has been unlinked.
func RequireGuild ¶
func RequireGuild(interaction discord.Interaction, handler BasicInteractionHandler) (*discord.InteractionResponse, error)
func RequireGuildElevation ¶
func RequireGuildElevation(sub *subway.Subway, interaction discord.Interaction, handler BasicInteractionHandler) (*discord.InteractionResponse, error)
Types ¶
type Attributes ¶
type Attributes struct { CurrentlyEntitledAmountCents int64 `json:"currently_entitled_amount_cents"` Email string `json:"email"` FullName string `json:"full_name"` ThumbUrl string `json:"thumb_url"` IsFollower bool `json:"is_follower"` LastChargeDate time.Time `json:"last_charge_date"` LastChargeStatus LastChargeStatus `json:"last_charge_status"` LifetimeSupportCents int64 `json:"lifetime_support_cents"` PatronStatus PatronStatus `json:"patron_status"` SocialConnections PatronSocialConnections `json:"social_connections"` }
type BasicInteractionHandler ¶
type BasicInteractionHandler func() (*discord.InteractionResponse, error)
type CustomEventInvokeBorderwallCompletionStructure ¶
type CustomEventInvokeBorderwallCompletionStructure struct {
Member discord.GuildMember
}
type CustomEventInvokeBorderwallStructure ¶
type CustomEventInvokeBorderwallStructure struct {
Member discord.GuildMember
}
type CustomEventInvokeTempChannelsRemoveStructure ¶
type CustomEventInvokeTempChannelsRemoveStructure struct { Interaction *discord.Interaction Member discord.GuildMember }
type CustomEventInvokeTempChannelsStructure ¶
type CustomEventInvokeTempChannelsStructure struct { Interaction *discord.Interaction Member discord.GuildMember }
type CustomEventInvokeWelcomerStructure ¶
type CustomEventInvokeWelcomerStructure struct { Interaction *discord.Interaction Member discord.GuildMember }
type GetPatreonMembersResponse ¶
type GetPatreonMembersResponse struct { Data []struct { Attributes Attributes `json:"attributes"` Relationships Relationships `json:"relationships"` } `json:"data"` Included []struct { Attributes Attributes `json:"attributes"` ID discord.Snowflake `json:"id"` Type string `json:"type"` } Links struct { Next string `json:"next"` } `json:"links"` }
type GuildSettingsTimeRolesRole ¶
type GuildSettingsTimeRolesRole struct { Role discord.Snowflake `json:"role_id"` Seconds int `json:"seconds"` }
func FilterAssignableTimeRoles ¶
func FilterAssignableTimeRoles(ctx context.Context, sandwichClient pb.SandwichClient, logger zerolog.Logger, guildID int64, applicationID int64, timeRoles []GuildSettingsTimeRolesRole) (out []GuildSettingsTimeRolesRole, err error)
func UnmarshalTimeRolesJSON ¶
func UnmarshalTimeRolesJSON(rolesJSON []byte) (roles []GuildSettingsTimeRolesRole)
type LastChargeStatus ¶
type LastChargeStatus string
const ( LastChargeStatusDeclined LastChargeStatus = "Declined" LastChargeStatusPaid LastChargeStatus = "Paid" LastChargeStatusDeleted LastChargeStatus = "Deleted" LastChargeStatusPending LastChargeStatus = "Pending" LastChargeStatusRefunded LastChargeStatus = "Refunded" LastChargeStatusFraud LastChargeStatus = "Fraud" LastChargeStatusOther LastChargeStatus = "Other" )
type OnInvokeBorderwallCompletionFuncType ¶
type OnInvokeBorderwallCompletionFuncType func(eventCtx *sandwich.EventContext, member CustomEventInvokeBorderwallCompletionStructure) error
type OnInvokeBorderwallFuncType ¶
type OnInvokeBorderwallFuncType func(eventCtx *sandwich.EventContext, member CustomEventInvokeBorderwallStructure) error
type OnInvokeLeaverFuncType ¶
type OnInvokeLeaverFuncType func(eventCtx *sandwich.EventContext, member CustomEventInvokeLeaverStructure) error
type OnInvokeTempChannelsFuncType ¶
type OnInvokeTempChannelsFuncType func(eventCtx *sandwich.EventContext, member CustomEventInvokeTempChannelsStructure) error
type OnInvokeTempChannelsRemoveFuncType ¶
type OnInvokeTempChannelsRemoveFuncType func(eventCtx *sandwich.EventContext, member CustomEventInvokeTempChannelsRemoveStructure) error
type OnInvokeWelcomerFuncType ¶
type OnInvokeWelcomerFuncType func(eventCtx *sandwich.EventContext, member CustomEventInvokeWelcomerStructure) error
type PatreonMember ¶
type PatreonMember struct { PatreonUserID discord.Snowflake `json:"patreon_user_id"` EntitledTiers []PatreonTier `json:"active_tier"` Attributes Attributes `json:"attributes"` }
func GetAllPatreonMembers ¶
func GetAllPatreonMembers(ctx context.Context, token string) ([]PatreonMember, error)
type PatreonTier ¶
type PatreonTier int64
const ( PatreonTierFree PatreonTier = 10503463 PatreonTierUnpublishedWelcomerDonator PatreonTier = 3975266 PatreonTierUnpublishedWelcomerPro1 PatreonTier = 3744919 PatreonTierUnpublishedWelcomerPro3 PatreonTier = 3744921 PatreonTierUnpublishedWelcomerPro5 PatreonTier = 3744926 PatreonTierWelcomerPro PatreonTier = 23606682 )
func (*PatreonTier) UnmarshalJSON ¶
func (s *PatreonTier) UnmarshalJSON(b []byte) error
type PatreonUser ¶
type PatreonUser struct { ID discord.Snowflake `json:"id"` Email string `json:"email"` FullName string `json:"full_name"` SocialConnections PatreonUser_SocialConnections `json:"social_connections"` ThumbURL string `json:"thumb_url"` }
func IdentifyPatreonMember ¶
func IdentifyPatreonMember(ctx context.Context, token string) (PatreonUser, error)
type PatreonUserOuter ¶
type PatreonUserOuter struct {
Data patreonUser `json:"data"`
}
type PatreonUser_Attributes ¶
type PatreonUser_Attributes struct { Email string `json:"email"` FullName string `json:"full_name"` SocialConnections PatreonUser_SocialConnections `json:"social_connections"` ThumbURL string `json:"thumb_url"` }
type PatreonUser_Discord ¶
type PatreonUser_SocialConnections ¶
type PatreonUser_SocialConnections struct {
Discord PatreonUser_Discord `json:"discord"`
}
type PatronSocialConnections ¶
type PatronStatus ¶
type PatronStatus string
const ( PatreonStatusNeverPledged PatronStatus = "" PatreonStatusActive PatronStatus = "active_patron" PatreonStatusDeclined PatronStatus = "declined_patron" PatreonStatusFormer PatronStatus = "former_patron" )
type PricingSKU ¶
type PricingSKU struct { ID SKUName `json:"id"` Name string `json:"name"` Description string `json:"-"` MembershipType database.MembershipType `json:"-"` SoftDescriptor string `json:"-"` // This should be 13 characters or less. MonthCount int `json:"month_count"` Costs map[Currency]string `json:"costs"` PatreonCheckoutId string `json:"patreon_checkout_id"` }
type Relationships ¶
type Relationships struct { CurrentlyEntitledTiers struct { Data []struct { ID PatreonTier `json:"id"` } `json:"data"` } `json:"currently_entitled_tiers"` User struct { Data struct { ID discord.Snowflake `json:"id"` } `json:"data"` } `json:"user"` }
type StubGuild ¶
type StubGuild struct { Name string `json:"name"` Icon string `json:"icon"` Splash string `json:"splash"` Banner string `json:"banner"` ID discord.Snowflake `json:"id"` Members int32 `json:"members"` }
Guild represents a guild on discord.
type StubInvite ¶
type StubInvite struct { ExpiresAt StubTime `json:"expires_at"` CreatedAt StubTime `json:"created_at"` Inviter StubUser `json:"inviter"` ChannelID discord.Snowflake `json:"channel"` Code string `json:"code"` Uses int32 `json:"uses"` MaxUses int32 `json:"max_uses"` MaxAge int32 `json:"max_age"` Temporary bool `json:"temporary"` }
Invite represents the invite used on discord.
type StubUser ¶
type StubUser struct { CreatedAt StubTime `json:"created_at"` JoinedAt StubTime `json:"joined_at"` Name string `json:"name"` Username string `json:"username"` Discriminator string `json:"discriminator"` GlobalName string `json:"global_name"` Mention string `json:"mention"` Avatar string `json:"avatar"` ID discord.Snowflake `json:"id"` Bot bool `json:"bot"` Pending bool `json:"pending"` }
StubUser represents a user on discord.
type WelcomerInteractionsContextKey ¶
type WelcomerInteractionsContextKey int
const ( PoolKey WelcomerInteractionsContextKey = iota QueriesKey ManagerNameKey )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.