Documentation ¶
Index ¶
- Constants
- Variables
- func CanPlaySound(s *models.SoundboardSound, roles []int64) bool
- func DownloadNewSoundFile(r io.Reader, w io.Writer, limit int) (tooBig bool, err error)
- func GetSoundboardSounds(guildID int64, ctx context.Context) ([]*models.SoundboardSound, error)
- func HandleDelete(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleGetCP(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleNew(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleUpdate(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func KeySoundLock(id int) string
- func ListSounds(sounds []*models.SoundboardSound, ms *dstate.MemberState) string
- func MaxSoundsForContext(ctx context.Context) int
- func RegisterPlugin()
- func RequestPlaySound(guildID int64, channelID, channelRanFrom int64, soundID int) (queued bool)
- func SoundFilePath(id int, status TranscodingStatus) string
- type PlayRequest
- type Player
- type Plugin
- func (p *Plugin) AddCommands()
- func (p *Plugin) InitWeb()
- func (p *Plugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func (p *Plugin) PluginInfo() *common.PluginInfo
- func (p *Plugin) RunBackgroundWorker()
- func (p *Plugin) StopBackgroundWorker(wg *sync.WaitGroup)
- type PostForm
- type TranscodingStatus
Constants ¶
View Source
const ( MaxGuildSounds = 50 MaxGuildSoundsPremium = 250 )
Variables ¶
View Source
var DBSchemas = []string{`
CREATE TABLE IF NOT EXISTS soundboard_sounds(
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
guild_id BIGINT NOT NULL,
required_role TEXT NOT NULL,
name TEXT NOT NULL,
status INT NOT NULL,
required_roles BIGINT[],
blacklisted_roles BIGINT[]
);
`, `
CREATE INDEX IF NOT EXISTS soundboard_sounds_guild_idx ON soundboard_sounds(guild_id);
`, `
-- i was using gorm way back, and that apperently didn't add not null constraints
-- so for existing tables make sure they're present
-- this SHOULD be impossible, but just to sure... (was 0 rows on prod db)
DELETE FROM soundboard_sounds WHERE guild_id IS NULL or required_role IS NULL or name IS NULL or status IS NULL or created_at IS NULL or updated_at IS NULL;
`, `
ALTER TABLE soundboard_sounds ALTER COLUMN guild_id SET NOT NULL;
`, `
ALTER TABLE soundboard_sounds ALTER COLUMN required_role SET NOT NULL;
`, `
ALTER TABLE soundboard_sounds ALTER COLUMN name SET NOT NULL;
`, `
ALTER TABLE soundboard_sounds ALTER COLUMN status SET NOT NULL;
`, `
ALTER TABLE soundboard_sounds ALTER COLUMN created_at SET NOT NULL;
`, `
ALTER TABLE soundboard_sounds ALTER COLUMN updated_at SET NOT NULL;
`, `
-- we migrate the data from the old system so that peoples settings dont dissapear
DO $$
BEGIN
IF (SELECT COUNT(*) FROM information_schema.columns WHERE table_name='soundboard_sounds' and column_name='required_roles') < 1 THEN
ALTER TABLE soundboard_sounds ADD COLUMN required_roles BIGINT[];
ALTER TABLE soundboard_sounds ADD COLUMN blacklisted_roles BIGINT[];
-- migrate
UPDATE soundboard_sounds SET required_roles=ARRAY[required_role]::BIGINT[] WHERE required_role IS NOT NULL AND required_role != '';
END IF;
END $$;
`}
View Source
var (
ErrVoiceSendTimeout = errors.New("Voice send timeout")
)
View Source
var (
Silence = []byte{0xF8, 0xFF, 0xFE}
)
Functions ¶
func CanPlaySound ¶ added in v1.13.0
func CanPlaySound(s *models.SoundboardSound, roles []int64) bool
func DownloadNewSoundFile ¶ added in v1.4.1
func GetSoundboardSounds ¶ added in v1.13.0
func HandleDelete ¶
func HandleDelete(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleGetCP ¶
func HandleGetCP(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleNew ¶
func HandleNew(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleUpdate ¶
func HandleUpdate(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func KeySoundLock ¶
func ListSounds ¶
func ListSounds(sounds []*models.SoundboardSound, ms *dstate.MemberState) string
func MaxSoundsForContext ¶ added in v1.6.0
func RegisterPlugin ¶
func RegisterPlugin()
func RequestPlaySound ¶
RequestPlaySound either queues up a sound to be played in an existing player or creates a new one
func SoundFilePath ¶
func SoundFilePath(id int, status TranscodingStatus) string
Types ¶
type PlayRequest ¶
type Player ¶ added in v1.24.6
type Player struct { GuildID int64 // below fields are safe to access with playersmu ChannelID int64 // contains filtered or unexported fields }
Player represends a voice connection playing a soundbaord file (or waiting for one)
type Plugin ¶
type Plugin struct{}
func (*Plugin) AddCommands ¶ added in v1.4.1
func (p *Plugin) AddCommands()
func (*Plugin) LoadServerHomeWidget ¶ added in v1.17.0
func (p *Plugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func (*Plugin) PluginInfo ¶ added in v1.17.0
func (p *Plugin) PluginInfo() *common.PluginInfo
func (*Plugin) RunBackgroundWorker ¶ added in v1.11.0
func (p *Plugin) RunBackgroundWorker()
func (*Plugin) StopBackgroundWorker ¶ added in v1.11.0
type PostForm ¶ added in v1.13.0
type PostForm struct { ID int Name string `valid:",100"` RequiredRoles []int64 `valid:"role"` BlacklistedRoles []int64 `valid:"role"` }
func (*PostForm) ToDBModel ¶ added in v1.13.0
func (pf *PostForm) ToDBModel() *models.SoundboardSound
type TranscodingStatus ¶
type TranscodingStatus int
const ( // In the transcoding queue TranscodingStatusQueued TranscodingStatus = iota // Done transcoding and ready to be played TranscodingStatusReady // Currently transcoding TranscodingStatusTranscoding // Failed transcoding, too long TranscodingStatusFailedLong // Failed transcofing, contact support TranscodingStatusFailedOther )
func (TranscodingStatus) String ¶
func (s TranscodingStatus) String() string
Click to show internal directories.
Click to hide internal directories.