Documentation ¶
Index ¶
- Constants
- Variables
- type AppQuestion
- type AppResponse
- type Application
- type ApplicationTrack
- type CommandOverrides
- type Config
- type ConfigOption
- type ConfigOptionType
- type ConfigSetting
- func (s ConfigSetting) ToBool() bool
- func (s ConfigSetting) ToChannelID() discord.ChannelID
- func (s ConfigSetting) ToFloat() float64
- func (s ConfigSetting) ToInt() int64
- func (s ConfigSetting) ToInterface() interface{}
- func (s ConfigSetting) ToRoleID() discord.RoleID
- func (s ConfigSetting) ToSnowflake() discord.Snowflake
- func (s ConfigSetting) ToString() string
- func (s ConfigSetting) ToUint() uint64
- func (s ConfigSetting) ToUserID() discord.UserID
- type DB
- func (db *DB) AddApplicationTrack(t ApplicationTrack) (*ApplicationTrack, error)
- func (db *DB) AddQuestion(trackID int64, question string) (err error)
- func (db *DB) AddResponse(appID xid.ID, resp AppResponse) error
- func (db *DB) AllInvites() (invs map[string]string, err error)
- func (db *DB) AllUserApplications(userID discord.UserID) (as []Application, err error)
- func (db *DB) ApplicationTrack(id int64) (*ApplicationTrack, error)
- func (db *DB) ApplicationTracks() (tracks []ApplicationTrack, err error)
- func (db *DB) ChannelApplication(chID discord.ChannelID) (*Application, error)
- func (db *DB) ClearInviteName(code string) error
- func (db *DB) CloseApplication(id xid.ID) error
- func (db *DB) CompleteApp(appID xid.ID) error
- func (db *DB) CreateApplication(userID discord.UserID, chID discord.ChannelID) (a Application, err error)
- func (db *DB) DeleteMessage(id discord.MessageID) (err error)
- func (db *DB) GetMessage(id discord.MessageID) (m *Message, err error)
- func (db *DB) InsertMessage(m Message) (err error)
- func (db *DB) InsertModLog(ctx context.Context, entry ModLogEntry) (ModLogEntry, error)
- func (db *DB) InviteName(code string) (name string)
- func (db *DB) ModLogFor(guildID discord.GuildID, userID discord.UserID) (es []ModLogEntry, err error)
- func (db *DB) Prefixer(m discord.Message) int
- func (db *DB) Questions(id int64) (qs []AppQuestion, err error)
- func (db *DB) ResetApplication(appID xid.ID) error
- func (db *DB) SetCloseID(appID xid.ID, eventID int64) error
- func (db *DB) SetEventID(appID xid.ID, eventID int64) error
- func (db *DB) SetInviteName(code, name string) error
- func (db *DB) SetQuestionIndex(appID xid.ID, index int) error
- func (db *DB) SetTrack(appID xid.ID, trackID int64) error
- func (db *DB) SetTranscript(appID xid.ID, chID discord.ChannelID, msgID discord.MessageID) error
- func (db *DB) SetVerified(appID xid.ID, mod discord.UserID, verified bool, denyReason *string) error
- func (db *DB) SyncConfig() error
- func (db *DB) SyncOverrides() error
- func (db *DB) SyncPerms() error
- func (db *DB) UpdateApplicationTrack(t ApplicationTrack) error
- func (db *DB) UpdateModLogMessage(id int64, chID discord.ChannelID, msgID discord.MessageID) (e ModLogEntry, err error)
- func (db *DB) UpdateModLogReason(id int64, reason string) (e ModLogEntry, err error)
- func (db *DB) UpdatePKInfo(msgID discord.MessageID, userID pkgo.Snowflake, system, member string) (err error)
- func (db *DB) UpdateUserID(msgID discord.MessageID, userID discord.UserID) (err error)
- func (db *DB) UserApplication(userID discord.UserID) (*Application, error)
- func (db *DB) UserStringGet(ctx context.Context, userID discord.UserID, key string) (string, error)
- func (db *DB) UserStringSet(userID discord.UserID, key, val string) error
- func (db *DB) UserTime(ctx context.Context, userID discord.UserID) *time.Location
- type Message
- type ModLogEntry
- type PermissionConfig
- type PermissionLevel
- type PermissionOverride
- type PermissionType
Constants ¶
const ArikawaDocumentationBase = "https://pkg.go.dev/github.com/diamondburned/arikawa/v3"
ArikawaDocumentationBase ...
Variables ¶
var ConfigOptions = map[string]ConfigOption{ "prefix": { Description: "The prefix used for bot commands. Case-insensitive.", Type: StringOptionType, DefaultValue: ".", }, "activity": { Description: "The activity shown in the bot's status.", Type: StringOptionType, DefaultValue: "", }, "activity_type": { Description: "The activity type shown in the bot's status. Valid options are: `playing`, `listening`, `watching`", Type: StringOptionType, DefaultValue: "playing", ValidValues: []interface{}{"playing", "listening", "watching"}, }, "status": { Description: "The bot's status. Valid options are: `online`, `idle`, `dnd`", Type: StringOptionType, DefaultValue: "online", ValidValues: []interface{}{"online", "idle", "dnd"}, }, "welcome_channel": { Description: "The channel new joins are announced in, and where they are welcomed if approved.", Type: SnowflakeOptionType, DefaultValue: 0, }, "welcome_message": { Description: "The message used to welcome someone. Accepted variables are:\n- `{{.Guild}}`: the [guild]({docs}/discord#Guild) the user is welcomed in\n- `{{.Member}}`: the [member]({docs}/discord#Member) that is being welcomed\n- `{{.Approver}}`: the [member]({docs}/discord#Member) that approved the user\n\nThis message is sent to `welcome_channel`.", Type: StringOptionType, DefaultValue: "Welcome to {{.Guild.Name}}, {{.Member.User.Mention}}!", }, "deny_message": { Description: "The message sent in `welcome_channel` when a user is denied. If empty, denials will not be posted publicly.\nAccepted variables are:\n- `{{.Guild}}`: the [guild]({docs}/discord#Guild) the user is denied in\n- `{{.User}}`: the [user]({docs}/discord#User) that was denied\n- `{{.Denier}}`: the [member]({docs}/discord#Member) that denied the user\n- `{{.Reason}}`: the reason the user was denied, or \"No reason specified\" if no reason was given.", Type: StringOptionType, DefaultValue: "{{.User.Mention}} ({{.User.Tag}}) was denied entry to the server by {{displayName .Denier}}.\nReason: {{.Reason}}", }, "application_category": { Description: "The category where application channels are created.", Type: SnowflakeOptionType, DefaultValue: 0, }, "finished_application_category": { Description: "The category that holds finished applications until they are closed.", Type: SnowflakeOptionType, DefaultValue: 0, }, "transcript_channel": { Description: "The channel where application transcripts are saved.", Type: SnowflakeOptionType, DefaultValue: 0, }, "discussion_channel": { Description: "The channel where newly finished applications are announced.", Type: SnowflakeOptionType, DefaultValue: 0, }, "application_channel_message": { Description: "The message that is posted in the applications channel. `{guild}` is replaced with the guild name.", Type: StringOptionType, DefaultValue: "Thank you for joining {guild}!\nWe hope you enjoy your stay.", }, "open_application_message": { Description: "The message that is posted when an application is opened. `{guild}` is replaced with the guild name.", Type: StringOptionType, DefaultValue: "Thank you for beginning your application for {guild}.", }, "application_finished_message": { Description: "The message that is posted when an application finishes.", Type: StringOptionType, DefaultValue: "Application finished! Please continue to add proof if it included more than one screenshot, and otherwise, please be patient until a mod can review your answers.", }, "long_answer_minimum": { Description: "Minimum number of words needed to advance questions where long answers are required.", Type: IntOptionType, DefaultValue: 3, }, "long_answer_message": { Description: "Message sent when someone's answer is too short. `{num}` is replaced with the number of words required.", Type: StringOptionType, DefaultValue: "Sorry, but your answer is too short! Please resend it, and make sure it's at least {num} words long.", }, "verified_role": { Description: "The role given to a member when they are approved.", Type: SnowflakeOptionType, DefaultValue: 0, }, "adult_role": { Description: "The role given to an adult member when they are approved.\n\nIf either this or `minor_role` is invalid, this step will be skipped and the valid role will be given.\nIf both this and `minor_role` are invalid, only `verified_role` will be given when a member is approved.", Type: SnowflakeOptionType, DefaultValue: 0, }, "minor_role": { Description: "The role given to a minor member when they are approved.\n\nIf either this or `adult_role` is invalid, this step will be skipped and the valid role will be given.\nIf both this and `adult_role` are invalid, only `verified_role` will be given when a member is approved.", Type: SnowflakeOptionType, DefaultValue: 0, }, "keep_application_visible": { Description: "Whether to keep the application channel visible to a member once they are approved.\n(If they are denied, the channel is hidden immediately)", Type: BoolOptionType, DefaultValue: false, }, "kick_on_deny": { Description: "Whether to kick a user immediately after they are denied with the `{prefix}deny` command. See also: `confirm_deny`, `dm_on_deny`.", Type: BoolOptionType, DefaultValue: false, }, "dm_on_deny": { Description: "Whether to DM a user if they are denied with the `{prefix}deny` command. See also: `confirm_deny`, `kick_on_deny`.", Type: BoolOptionType, DefaultValue: false, }, "confirm_deny": { Description: "Whether to show a confirmation prompt for the `{prefix}deny` command. See also: `dm_on_deny`, `kick_on_deny`.", Type: BoolOptionType, DefaultValue: false, }, "join_leave_log": { Description: "The channel to log members joining and leaving in (for mods).", Type: SnowflakeOptionType, DefaultValue: 0, }, "invite_channel": { Description: "The channel to create invites in.", Type: SnowflakeOptionType, DefaultValue: 0, }, "username_role_log": { Description: "The channel to log name and role changes in.", Type: SnowflakeOptionType, DefaultValue: 0, }, "message_log": { Description: "The channel to log message updates and deletes in.", Type: SnowflakeOptionType, DefaultValue: 0, }, "mod_log": { Description: "The channel to log moderator actions in.", Type: SnowflakeOptionType, DefaultValue: 0, }, "mute_role": { Description: "The role to give to people with the `{prefix}mute` command.", Type: SnowflakeOptionType, DefaultValue: 0, }, }
ConfigOptions are all configuration options
var DefaultPermissions = map[string]PermissionLevel{ "ping": EveryoneLevel, "help": UserLevel, "config": OwnerLevel, "permissions": OwnerLevel, "app": StaffLevel, "verify": HelperLevel, "close": HelperLevel, "deny": HelperLevel, "logs": HelperLevel, "userinfo": UserLevel, "unverified": StaffLevel, "level": UserLevel, "levelcfg": StaffLevel, "leaderboard": UserLevel, "restart": HelperLevel, "invites": StaffLevel, "open": HelperLevel, "hello": EveryoneLevel, "valid": EveryoneLevel, "transcript": StaffLevel, "remindme": EveryoneLevel, "warn": HelperLevel, "mute": HelperLevel, "hardmute": HelperLevel, "unmute": HelperLevel, "kick": StaffLevel, "ban": StaffLevel, "unban": StaffLevel, "modlogs": HelperLevel, "stats": HelperLevel, "charinfo": HelperLevel, }
DefaultPermissions ...
var (
ErrInvalidConfigOption = errors.New("invalid configuration option")
)
Configuration errors
var OverridesMu sync.RWMutex
Functions ¶
This section is empty.
Types ¶
type AppQuestion ¶
AppQuestion is a single application question.
type AppResponse ¶
type AppResponse struct { ApplicationID xid.ID MessageID discord.MessageID UserID discord.UserID Username string Discriminator string Content string FromBot bool FromStaff bool }
AppResponse ...
type Application ¶
type Application struct { ID xid.ID UserID discord.UserID ChannelID discord.ChannelID // Can be null before a track is chosen + if the track is deleted TrackID *int64 // Question index Question int // Whether the user has completed the automated interview section Completed bool // Whether the user was verified--null if not decided yet Verified *bool // If Verified is false, the reason why the user was denied DenyReason *string // Moderator who verified or denied the user Moderator *discord.UserID // Whether the interview has been closed (channel deleted) Closed bool ClosedTime *time.Time TranscriptChannel *discord.ChannelID TranscriptMessage *discord.MessageID // The scheduled event used to notify when the app times out ScheduledEventID *int64 ScheduledCloseID *int64 }
Application is a user's application.
type ApplicationTrack ¶
type ApplicationTrack struct { ID int64 Name string Description string // RawEmoji is stored as a?:name:id RawEmoji string `db:"emoji"` }
ApplicationTrack is a single list of questions and associated name.
func (ApplicationTrack) Emoji ¶
func (t ApplicationTrack) Emoji() discord.Emoji
Emoji returns the emoji struct version of the stored emoji.
type CommandOverrides ¶
type CommandOverrides map[string]PermissionLevel
CommandOverrides is a map of command permission level overrides.
Command permission levels: - 1: @everyone - 2: normal users - 3: chat moderators/helpers - 4: staff - 5: owner
func (CommandOverrides) For ¶
func (c CommandOverrides) For(cmd string) PermissionLevel
For returns the permission level for the given command.
type Config ¶
type Config map[string]interface{}
Config is a server's configuration.
func (Config) Get ¶
func (c Config) Get(name string) ConfigSetting
Get gets the given configuration setting. *This method panics if an invalid option name is given.*
type ConfigOption ¶
type ConfigOption struct { Description string Type ConfigOptionType DefaultValue interface{} ValidValues []interface{} }
ConfigOption is a single configuration option definition
type ConfigOptionType ¶
type ConfigOptionType int
ConfigOptionType is the configuration option's type (string, bool, float, int)
const ( InvalidOptionType ConfigOptionType = iota StringOptionType BoolOptionType IntOptionType FloatOptionType SnowflakeOptionType )
Option type constants
func (ConfigOptionType) String ¶
func (t ConfigOptionType) String() string
type ConfigSetting ¶
type ConfigSetting struct {
// contains filtered or unexported fields
}
ConfigSetting ...
func (ConfigSetting) ToBool ¶
func (s ConfigSetting) ToBool() bool
ToBool returns the ConfigSetting as a bool
func (ConfigSetting) ToChannelID ¶
func (s ConfigSetting) ToChannelID() discord.ChannelID
ToChannelID returns the ConfigSetting as a discord.ChannelID
func (ConfigSetting) ToFloat ¶
func (s ConfigSetting) ToFloat() float64
ToFloat returns the ConfigSetting as a float64
func (ConfigSetting) ToInt ¶
func (s ConfigSetting) ToInt() int64
ToInt returns the ConfigSetting as an int64
func (ConfigSetting) ToInterface ¶
func (s ConfigSetting) ToInterface() interface{}
ToInterface returns the ConfigSetting as an interface
func (ConfigSetting) ToRoleID ¶
func (s ConfigSetting) ToRoleID() discord.RoleID
ToRoleID returns the ConfigSetting as a discord.RoleID
func (ConfigSetting) ToSnowflake ¶
func (s ConfigSetting) ToSnowflake() discord.Snowflake
ToSnowflake returns the ConfigSetting as a discord.Snowflake
func (ConfigSetting) ToString ¶
func (s ConfigSetting) ToString() string
ToString returns the ConfigSetting as a string
func (ConfigSetting) ToUint ¶
func (s ConfigSetting) ToUint() uint64
ToUint returns the ConfigSetting as a uint64
func (ConfigSetting) ToUserID ¶
func (s ConfigSetting) ToUserID() discord.UserID
ToUserID returns the ConfigSetting as a discord.UserID
type DB ¶
type DB struct { *pgxpool.Pool BotConfig common.BotConfig Config Config Perms PermissionConfig Overrides CommandOverrides }
DB ...
func (*DB) AddApplicationTrack ¶
func (db *DB) AddApplicationTrack(t ApplicationTrack) (*ApplicationTrack, error)
AddApplicationTrack adds an application track to the database.
func (*DB) AddQuestion ¶
AddQuestion ...
func (*DB) AddResponse ¶
func (db *DB) AddResponse(appID xid.ID, resp AppResponse) error
AddResponse adds or updates a response to an application.
func (*DB) AllUserApplications ¶
func (db *DB) AllUserApplications(userID discord.UserID) (as []Application, err error)
AllUserApplications returns all of this user's applications, sorted by ID descending.
func (*DB) ApplicationTrack ¶
func (db *DB) ApplicationTrack(id int64) (*ApplicationTrack, error)
ApplicationTrack ...
func (*DB) ApplicationTracks ¶
func (db *DB) ApplicationTracks() (tracks []ApplicationTrack, err error)
ApplicationTracks returns all application tracks sorted by ID.
func (*DB) ChannelApplication ¶
func (db *DB) ChannelApplication(chID discord.ChannelID) (*Application, error)
ChannelApplication ...
func (*DB) ClearInviteName ¶
func (*DB) CloseApplication ¶
CloseApplication closes the given application.
func (*DB) CreateApplication ¶
func (db *DB) CreateApplication(userID discord.UserID, chID discord.ChannelID) (a Application, err error)
CreateApplication ...
func (*DB) DeleteMessage ¶
DeleteMessage deletes a message from the database
func (*DB) GetMessage ¶
GetMessage gets a single message
func (*DB) InsertMessage ¶
InsertMessage inserts a message
func (*DB) InsertModLog ¶
func (db *DB) InsertModLog(ctx context.Context, entry ModLogEntry) (ModLogEntry, error)
func (*DB) InviteName ¶
func (*DB) Questions ¶
func (db *DB) Questions(id int64) (qs []AppQuestion, err error)
Questions gets all questions for an interview track.
func (*DB) SetInviteName ¶
func (*DB) SetQuestionIndex ¶
SetQuestionIndex ...
func (*DB) SetTranscript ¶
SetTranscript ...
func (*DB) SetVerified ¶
func (db *DB) SetVerified(appID xid.ID, mod discord.UserID, verified bool, denyReason *string) error
SetVerified ...
func (*DB) SyncConfig ¶
SyncConfig synchronizes configuration with the database.
func (*DB) SyncOverrides ¶
SyncOverrides synchronizes command overrides with the database.
func (*DB) UpdateApplicationTrack ¶
func (db *DB) UpdateApplicationTrack(t ApplicationTrack) error
UpdateApplicationTrack updates the given application track.
func (*DB) UpdateModLogMessage ¶
func (*DB) UpdateModLogReason ¶
func (db *DB) UpdateModLogReason(id int64, reason string) (e ModLogEntry, err error)
func (*DB) UpdatePKInfo ¶
func (db *DB) UpdatePKInfo(msgID discord.MessageID, userID pkgo.Snowflake, system, member string) (err error)
UpdatePKInfo updates the PluralKit info for the given message, if it exists in the database.
func (*DB) UpdateUserID ¶
UpdateUserID updates *just* the user ID for the given message, if it exists in the database.
func (*DB) UserApplication ¶
func (db *DB) UserApplication(userID discord.UserID) (*Application, error)
UserApplication returns an open application for the given user.
func (*DB) UserStringGet ¶
func (*DB) UserStringSet ¶
type Message ¶
type Message struct { ID discord.MessageID UserID discord.UserID ChannelID discord.ChannelID ServerID discord.GuildID Content string Username string // These are only filled if the message was proxied by PluralKit Member *string System *string }
Message is a single message
type ModLogEntry ¶
type PermissionConfig ¶
type PermissionConfig struct { BotOwners []discord.UserID `json:"-"` User []PermissionOverride `json:"user"` Helper []PermissionOverride `json:"helper"` Staff []PermissionOverride `json:"staff"` Owner []PermissionOverride `json:"owner"` }
PermissionConfig ...
func (PermissionConfig) Level ¶
func (p PermissionConfig) Level(m *discord.Member) PermissionLevel
Level returns the permission level of the given member.
type PermissionLevel ¶
type PermissionLevel int
PermissionLevel is command permission levels
const ( InvalidLevel PermissionLevel = 0 EveryoneLevel PermissionLevel = 1 UserLevel PermissionLevel = 2 HelperLevel PermissionLevel = 3 StaffLevel PermissionLevel = 4 OwnerLevel PermissionLevel = 5 DisabledLevel PermissionLevel = 6 )
Permission level constants
func (PermissionLevel) String ¶
func (p PermissionLevel) String() string
type PermissionOverride ¶
type PermissionOverride struct { ID discord.Snowflake `json:"id"` Type PermissionType `json:"type"` }
PermissionOverride ...
type PermissionType ¶
type PermissionType int
PermissionType is command permission types
const ( UserPermission PermissionType = 0 RolePermission PermissionType = 1 )
Permission type constants