tickets

package
v1.31.14 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTicketMsg        = "{{$embed := cembed `description` (joinStr `` `Welcome ` .User.Mention `\n\nPlease describe the reasoning for opening this ticket, include any information you think may be relevant such as proof, other third parties and so on.` " + DefaultTicketMsgClose + DefaultTicketMsgAddUser + ")}}\n{{sendMessage nil $embed}}"
	DefaultTicketMsgClose   = "\n\"\\n\\nuse the following command to close the ticket\\n\"\n\"`-ticket close reason for closing here`\\n\\n\""
	DefaultTicketMsgAddUser = "\n\"use the following command to add users to the ticket\\n\"\n\"`-ticket adduser @user`\""
)
View Source
const InTicketPerms = discordgo.PermissionReadMessageHistory | discordgo.PermissionReadMessages | discordgo.PermissionSendMessages | discordgo.PermissionEmbedLinks | discordgo.PermissionAttachFiles
View Source
const TicketTXTDateFormat = "2006 Jan 02 15:04:05"

Variables

View Source
var DBSchemas = []string{`
CREATE TABLE IF NOT EXISTS ticket_configs  (
	guild_id BIGINT PRIMARY KEY,

	enabled BOOLEAN NOT NULL,

	ticket_open_msg TEXT NOT NULL,

	tickets_channel_category BIGINT NOT NULL,
	status_channel BIGINT NOT NULL,
	tickets_transcripts_channel BIGINT NOT NULL,
	download_attachments BOOLEAN NOT NULL,
	tickets_use_txt_transcripts BOOLEAN NOT NULL,

	mod_roles BIGINT[],
	admin_roles BIGINT[]
);
`, `
ALTER TABLE ticket_configs ADD COLUMN IF NOT EXISTS tickets_transcripts_channel_admin_only BIGINT NOT NULL DEFAULT 0;
`, `
CREATE TABLE IF NOT EXISTS tickets (
	guild_id BIGINT NOT NULL,
	local_id BIGINT NOT NULL,

	channel_id BIGINT NOT NULL,

	title TEXT NOT NULL,

	created_at TIMESTAMP WITH TIME ZONE NOT NULL,
	closed_at TIMESTAMP WITH TIME ZONE,

	logs_id BIGINT NOT NULL,

	author_id BIGINT NOT NULL,
	author_username_discrim TEXT NOT NULL,

	PRIMARY KEY(guild_id, local_id)
);

`, `
CREATE INDEX IF NOT EXISTS tickets_guild_id_channel_id_idx ON tickets(guild_id, channel_id);

`, `
CREATE TABLE IF NOT EXISTS ticket_participants (
	ticket_guild_id BIGINT NOT NULL,
	ticket_local_id BIGINT NOT NULL,

	user_id BIGINT NOT NULL,
	username TEXT NOT NULL,
	discrim TEXT NOT NULL,

	is_staff BOOLEAN NOT NULL,

	-- This is bugged in sqlboiler, sooooo don't use it for now i guess
	-- FOREIGN KEY (ticket_guild_id, ticket_local_id) REFERENCES tickets(guild_id, local_id) ON DELETE CASCADE,

	PRIMARY KEY(ticket_guild_id, ticket_local_id, user_id)


);
`, `

CREATE INDEX IF NOT EXISTS ticket_participants_ticket_local_id_idx ON ticket_participants(ticket_guild_id, ticket_local_id);
`}
View Source
var PageHTML string

Functions

func CreateTicket added in v1.28.0

func CreateTicket(ctx context.Context, gs *dstate.GuildSet, ms *dstate.MemberState, conf *models.TicketConfig, topic string, checkMaxTickets bool) (*dstate.GuildSet, *models.Ticket, error)

func RegisterPlugin

func RegisterPlugin()

func RequireActiveTicketMW

func RequireActiveTicketMW(inner dcmd.RunFunc) dcmd.RunFunc

func TicketCommandsRolesRunFuncfunc added in v1.26.3

func TicketCommandsRolesRunFuncfunc(gs *dstate.GuildSet) ([]int64, error)

func TicketLog

func TicketLog(conf *models.TicketConfig, guildID int64, author *discordgo.User, embed *discordgo.MessageEmbed)

Types

type CtxKey

type CtxKey int
const (
	CtxKeyConfig        CtxKey = iota
	CtxKeyCurrentTicket CtxKey = iota
)

type FormData

type FormData struct {
	GuildID                            int64
	Enabled                            bool
	TicketsChannelCategory             int64 `valid:"channel,true"`
	TicketsTranscriptsChannel          int64 `valid:"channel,true"`
	TicketsTranscriptsChannelAdminOnly int64 `valid:"channel,true"`
	StatusChannel                      int64 `valid:"channel,true"`
	TicketsUseTXTTranscripts           bool
	DownloadAttachments                bool
	ModRoles                           []int64 `valid:"role"`
	AdminRoles                         []int64 `valid:"role"`
	TicketOpenMSG                      string  `valid:"template,10000"`
}

type Plugin

type Plugin struct{}

func (*Plugin) AddCommands

func (p *Plugin) AddCommands()

func (*Plugin) BotInit

func (p *Plugin) BotInit()

func (*Plugin) InitWeb

func (p *Plugin) InitWeb()

func (*Plugin) LoadServerHomeWidget

func (p *Plugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func (*Plugin) PluginInfo

func (p *Plugin) PluginInfo() *common.PluginInfo

type TemplateTicket added in v1.28.0

type TemplateTicket struct {
	GuildID               int64
	LocalID               int64
	ChannelID             int64
	Title                 string
	CreatedAt             time.Time
	ClosedAt              null.Time
	LogsID                int64
	AuthorID              int64
	AuthorUsernameDiscrim string
}

type Ticket

type Ticket struct {
	Ticket       *models.Ticket
	Participants []*models.TicketParticipant
}

type TicketUserError added in v1.28.0

type TicketUserError string
const (
	ErrNoTicketCateogry TicketUserError = "No category for ticket channels set"
	ErrTitleTooLong     TicketUserError = "" /* 127-byte string literal not displayed */
	ErrMaxOpenTickets   TicketUserError = "You're currently in over 10 open tickets on this server, please close some of the ones you're in."
)

func (TicketUserError) Error added in v1.28.0

func (t TicketUserError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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