Skip to content

Conversation

@ItsRauf
Copy link
Contributor

@ItsRauf ItsRauf commented Dec 20, 2025

closes #31

Custom Sapphire Client (apps/bot/src/client.ts)

  • Created EmbedlyClient extending SapphireClient
  • Initializes Logtail logger in login() method
  • Properly flushes logs in destroy() method for graceful shutdown
  • Encapsulates client configuration (intents, presence) in constructor

Container Extensions (apps/bot/src/client.ts)

  • Added betterstack: Logtail to Sapphire container
  • Added embed_authors: Map<string, string> for message tracking
  • Accessible via this.container.betterstack in all commands/listeners

Base Interfaces (packages/logging/src/main.ts)

  • Created EmbedlyLogBase interface for all log types (info, warn, error)
  • Extended EmbedlyErrorBase from EmbedlyLogBase for backward compatibility
  • Updated formatBetterStack to accept EmbedlyLogBase instead of just errors

New Log Definitions

  • Info logs: EMBEDLY_EMBED_CREATED_COMMAND, EMBEDLY_EMBED_CREATED_MESSAGE, EMBEDLY_DELETE_SUCCESS_INFO
  • Warn logs: EMBEDLY_NO_LINK_WARN, EMBEDLY_NO_VALID_LINK_WARN, EMBEDLY_DELETE_FAILED_WARN
  • Added context interfaces: EmbedlyEmbedContext, EmbedlyDeleteContext
  • Made EmbedlyPostContext fields optional for flexible context merging

Logging Implementation

  • All validation failures logged as warnings with context
  • All successful operations logged as info with full metadata
  • All API errors logged with structured error context
  • Platform names in log types now uppercase (e.g., EMBEDLY_FETCH_TWITTER)

In-Memory Author Tracking

  • Track original message author ID in container.embed_authors Map
  • Store mapping when bot creates embeds (messageCreate listener, embed command)
  • Enables deletion even when original message is deleted

Fallback Strategy

  • Primary: Use in-memory mapping (survives message deletion)
  • Fallback: Fetch Discord reference message if mapping unavailable
  • Graceful failure with proper logging when both methods fail

Better Error Handling

  • Refactored to use early returns over nested conditions
  • Clear permission checks with descriptive variable names
  • Contextual logging with reason field for debugging

Dependencies

  • Added @logtail/node to apps/bot/package.json

…te command

added betterstack logging to the bot with a custom sapphire client. implemented an in-memory author tracking for the delete command to handle the delete command better. improved error handling.
idk what it was doing there lowk, the api is a cf worker so...
closes #31. ups a bunch of deps cus i aint touch ts in a while
this should be fine but maybe it breaks idk i can come back to this later
@changeset-bot
Copy link

changeset-bot bot commented Dec 20, 2025

🦋 Changeset detected

Latest commit: ea766ea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@embedly/logging Minor
@embedly/bot Minor
@embedly/platforms Minor
@embedly/api Minor
@embedly/builder Minor
@embedly/config Minor
@embedly/parser Minor
@embedly/types Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ItsRauf ItsRauf merged commit 4bf61f5 into main Dec 20, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants