Documentation
¶
Index ¶
- Constants
- func SetDB(d *mongo.MongoDB)
- func Start()
- type Config
- type CustomCommand
- func (cc *CustomCommand) AddToShop(s *Shop) error
- func (cc *CustomCommand) Purchase(s *discordgo.Session, memberID string) (*Purchase, error)
- func (cc *CustomCommand) RemoveFromShop(s *Shop) error
- func (cc *CustomCommand) Update(name string, description string, price int, duration string, ...) error
- type Member
- type Plugin
- func (plugin *Plugin) GetAdminHelp() []string
- func (plugin *Plugin) GetCommandHandlers() map[string]func(*discordgo.Session, *discordgo.InteractionCreate)
- func (plugin *Plugin) GetCommands() []*discordgo.ApplicationCommand
- func (plugin *Plugin) GetComponentHandlers() map[string]func(*discordgo.Session, *discordgo.InteractionCreate)
- func (plugin *Plugin) GetHelp() []string
- func (plugin *Plugin) GetName() string
- func (plugin *Plugin) Initialize(b *discord.Bot, d *mongo.MongoDB)
- func (plugin *Plugin) Status() discord.PluginStatus
- func (plugin *Plugin) Stop()
- type Purchase
- type Role
- type Shop
- type ShopItem
Constants ¶
const ( CUSTOM_COMMAND = "custom_command" CUSTOM_COMMAND_NAME = "Custom Command" CUSTOM_COMMAND_DESCRIPTION = "Custom command that may be used on this server" )
const ( CONFIG_COLLECTION = "shop_configs" SHOP_ITEM_COLLECTION = "shop_items" PURCHASE_COLLECTION = "shop_purchases" MEMBER_COLLECTION = "shop_members" )
const ( PLUGIN_NAME = "shop" PURCHASES_PER_PAGE = 5 )
const ( APPROVED = "approved" DENIED = "denied" PENDING = "pending" PURCHASED = "purchased" )
const (
MAX_SHOP_ITEMS_DISPLAYED = 25
)
const (
ROLE = "role"
)
const (
SHOP_BAN = "shop"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { ID primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"` GuildID string `json:"guild_id" bson:"guild_id"` ChannelID string `json:"channel_id" bson:"channel_id"` MessageID string `json:"message_id" bson:"message_id"` ModChannelID string `json:"mod_channel_id" bson:"mod_channel_id"` NotificationID string `json:"notification_id" bson:"notification_id"` }
Config represents the configuration for the shop in a guild.
func GetConfig ¶
GetConfig reads the configuration from the database. If the config does not exist, then one is created.
func (*Config) SetChannel ¶
SetChannel sets the channel to which to publish the shop items
func (*Config) SetMessageID ¶
SetMessageID saves the interaction used to publish the shop items.
func (*Config) SetModChannel ¶
SetModChannel sets the channel to which to publish the shop purchases and expirations.
func (*Config) SetNotificationID ¶
SetModChannel sets the channel to which to notify a user (e.g., ModMail) about an action to take to complete a member's purchase.
type CustomCommand ¶
type CustomCommand ShopItem
CustomCommand represents a custom command item in the shop.
func GetCustomCommand ¶
func GetCustomCommand(guildID string, name string) *CustomCommand
GetCustomCommand retrieves a custom command from the shop by its name for a specific guild.
func NewCustomCommand ¶
func NewCustomCommand(guildID string, name string, description string, price int) *CustomCommand
NewCustomCommand creates a new command for the shop.
func (*CustomCommand) AddToShop ¶
func (cc *CustomCommand) AddToShop(s *Shop) error
AddToShop adds the command to the shop. If the command already exists, an error is returned.
func (*CustomCommand) RemoveFromShop ¶
func (cc *CustomCommand) RemoveFromShop(s *Shop) error
RemoveFromShop removes the command from the shop. If the command does not exist, an error is returned.
type Member ¶
type Member struct { ID primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"` GuildID string `json:"guild_id,omitempty" bson:"guild_id,omitempty"` MemberID string `json:"member_id,omitempty" bson:"member_id,omitempty"` Restrictions []string `json:"restrictions,omitempty" bson:"restrictions,omitempty"` }
Member represents a member of a guild with restrictions on what they can or cannot do in a shop.
func (*Member) AddRestriction ¶
AddRestriction adds a restriction to the member.
func (*Member) HasRestriction ¶
HasRestriction checks if the member has a specific restriction.
func (*Member) RemoveRestriction ¶
RemoveRestriction removes a restriction from the member.
type Plugin ¶
type Plugin struct{}
Plugin is the plugin for the banking system used by the bot
func (*Plugin) GetAdminHelp ¶
GetAdminHelp returns the admin help for the banking system
func (*Plugin) GetCommandHandlers ¶
func (plugin *Plugin) GetCommandHandlers() map[string]func(*discordgo.Session, *discordgo.InteractionCreate)
GetCommandHandlers returns the command handlers for the banking system
func (*Plugin) GetCommands ¶
func (plugin *Plugin) GetCommands() []*discordgo.ApplicationCommand
GetCommands returns the commands for the banking system
func (*Plugin) GetComponentHandlers ¶
func (plugin *Plugin) GetComponentHandlers() map[string]func(*discordgo.Session, *discordgo.InteractionCreate)
GetComponentHandlers returns the component handlers for the banking system
func (*Plugin) Initialize ¶
Initialize saves the Discord bot to be used by the banking system
func (*Plugin) Status ¶
func (plugin *Plugin) Status() discord.PluginStatus
Status returns the status of the heist game. This is used to determine if the plugin is running or not.
type Purchase ¶
type Purchase struct { ID primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"` GuildID string `json:"guild_id" bson:"guild_id"` MemberID string `json:"member_id" bson:"member_id"` Item *ShopItem `json:"item" bson:"item,inline"` Status string `json:"status" bson:"status"` PurchasedOn time.Time `json:"purchased_on" bson:"purchased_on"` ExpiresOn time.Time `json:"expires_on" bson:"expires_on"` AutoRenew bool `json:"auto_renew" bson:"auto_renew"` IsExpired bool `json:"is_expired" bson:"is_expired"` }
Purchase is a purchase made from the shop.
func GetAllPurchases ¶
GetAllRoles returns all the purchases made by a member in the guild.
func GetPurchase ¶
GetPurchase returns the purchase made by a member in the guild for the given item name. If the purchase does not exist, nil is returned.
func PurchaseItem ¶
func PurchaseItem(guildID, memberID string, item *ShopItem, status string, renew bool) (*Purchase, error)
PurchaseItem creates a new Purchase with the given guild ID, member ID, and a purchasable shop item.
func (*Purchase) HasExpired ¶
Determine if a purchase has expired. This marks the purchase as expired and undoes the effects of the purchase if it has expired.
type Role ¶
type Role ShopItem
Role represents a role item in the shop.
func NewRole ¶
func NewRole(guildID string, name string, description string, price int, duration string, autoRenewable bool) *Role
NewRole creates a new role for the shop.
func (*Role) AddToShop ¶
AddToShop adds the role to the shop. If the role already exists, an error is returned.
func (*Role) RemoveFromShop ¶
RemoveFromShop removes the role from the shop. If the role does not exist, an error is returned.
type Shop ¶
type Shop struct { GuildID string // Guild (server) for the shop Items []*ShopItem // All items available in the shop }
The shop for a guild. The shop contains all items available for purchase.
type ShopItem ¶
type ShopItem struct { ID primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"` GuildID string `json:"guild_id" bson:"guild_id"` Name string `json:"name" bson:"name"` Description string `json:"description" bson:"description"` Type string `json:"type" bson:"type"` Price int `json:"price" bson:"price"` Duration string `json:"duration,omitempty" bson:"duration,omitempty"` AutoRenewable bool `json:"auto_renewable,omitempty" bson:"auto_renewable,omitempty"` }
ShopItem represents an item in the shop, which represents any purchasable item.