- Introduced a new welcome service and repository for managing welcome messages, channels, and GIFs. - Added commands to set welcome channel, message, DM, and GIF through the bot's configuration. - Implemented event handling for new guild members to send welcome messages and DMs based on configuration. - Updated main application to include the new welcome service in the bot's services.
37 lines
895 B
Go
37 lines
895 B
Go
package welcome
|
|
|
|
import (
|
|
"context"
|
|
|
|
"velox-bot/internal/db/repos/welcomerepo"
|
|
)
|
|
|
|
type Service struct {
|
|
repo *welcomerepo.Repo
|
|
}
|
|
|
|
func New(repo *welcomerepo.Repo) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) GetSettings(ctx context.Context, guildID int64) (*welcomerepo.Settings, error) {
|
|
return s.repo.GetSettings(ctx, guildID)
|
|
}
|
|
|
|
func (s *Service) SetChannel(ctx context.Context, guildID, channelID int64) error {
|
|
return s.repo.UpsertChannel(ctx, guildID, channelID)
|
|
}
|
|
|
|
func (s *Service) SetMessage(ctx context.Context, guildID int64, message string) error {
|
|
return s.repo.UpsertMessage(ctx, guildID, message)
|
|
}
|
|
|
|
func (s *Service) SetDM(ctx context.Context, guildID int64, dm string) error {
|
|
return s.repo.UpsertDM(ctx, guildID, dm)
|
|
}
|
|
|
|
func (s *Service) SetGIF(ctx context.Context, guildID int64, gifURL string) error {
|
|
return s.repo.UpsertGIF(ctx, guildID, gifURL)
|
|
}
|
|
|