Skip to content

Commit

Permalink
update: log creator adds
Browse files Browse the repository at this point in the history
Log creators as they're added for better issue detection. I'll be able
to look at the api response in full of creators that may crash the bot
when attempting to be added.
  • Loading branch information
fvckgrimm committed Dec 21, 2024
1 parent 66f2d4d commit c865ff8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ DISCORD_TOKEN=<YOUR_BOT_TOKEN>
PUBLIC_KEY=<YOUR_PUBLIC_KEY>
FANSLY_TOKEN=<YOUR_FANSLY_TOKEN>
USER_AGENT=<YOUR_BROWSER_USER_AGENT>
LOG_CHANNEL_ID=<CHANNEL_ID_TO_LOG_ADDED_CREATORS>
13 changes: 13 additions & 0 deletions internal/bot/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/bwmarrin/discordgo"
"github.com/fvckgrimm/discord-fansly-notify/internal/config"
)

func (b *Bot) ready(s *discordgo.Session, event *discordgo.Ready) {
Expand Down Expand Up @@ -46,6 +47,18 @@ func (b *Bot) handleAddCommand(s *discordgo.Session, i *discordgo.InteractionCre
}
}

// Log What Creators are being monitored to better handle potential issues
logMessage := fmt.Sprintf("`[ %s ]` %s:\n`Requested Creator Name:` **%s**\n----------",
time.Now().Format("2006-01-02 15:04:05"),
i.Member.User.Username,
username,
)

_, err := s.ChannelMessageSend(config.LogChannelID, logMessage)
if err != nil {
log.Printf("Failed to send log message: %v", err)
}

accountInfo, err := b.APIClient.GetAccountInfo(username)
if err != nil {
log.Printf("Error getting account info for %s: %v", username, err)
Expand Down
4 changes: 3 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var (
UserAgent string
AppID string
PublicKey string
LogChannelID string
)

func Load() {
Expand All @@ -26,8 +27,9 @@ func Load() {
UserAgent = os.Getenv("USER_AGENT")
AppID = os.Getenv("APP_ID")
PublicKey = os.Getenv("PUBLIC_KEY")
LogChannelID = os.Getenv("LOG_CHANNEL_ID")

if DiscordToken == "" || FanslyToken == "" || UserAgent == "" || AppID == "" || PublicKey == "" {
if DiscordToken == "" || FanslyToken == "" || UserAgent == "" || AppID == "" || PublicKey == "" || LogChannelID == "" {
log.Fatal("Missing required environment variables")
}
}

0 comments on commit c865ff8

Please sign in to comment.