- Added a logging service to manage server event logs including message edits, deletions, member joins/leaves, and moderation actions. - Introduced commands to configure logging settings, including setting the log channel and enabling/disabling logging. - Updated the README to document the new logging features and commands. - Enhanced moderation commands to log actions taken on members.
31 lines
668 B
Go
31 lines
668 B
Go
package modlog
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"velox-bot/internal/db/services"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
)
|
|
|
|
func Send(s *discordgo.Session, svc *services.Services, guildID string, embed *discordgo.MessageEmbed) error {
|
|
if s == nil || svc == nil || svc.LogSettings == nil || embed == nil || guildID == "" {
|
|
return nil
|
|
}
|
|
|
|
gid, err := strconv.ParseInt(guildID, 10, 64)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
|
|
cfg, err := svc.LogSettings.GetSettings(context.Background(), gid)
|
|
if err != nil || cfg == nil || !cfg.IsEnabled || cfg.ChannelID == 0 {
|
|
return err
|
|
}
|
|
|
|
_, err = s.ChannelMessageSendEmbed(strconv.FormatInt(cfg.ChannelID, 10), embed)
|
|
return err
|
|
}
|
|
|