Skip to content

fix async imports#220

Merged
GalvinPython merged 4 commits into
mainfrom
chore/2.0.1
Jun 19, 2026
Merged

fix async imports#220
GalvinPython merged 4 commits into
mainfrom
chore/2.0.1

Conversation

@GalvinPython

Copy link
Copy Markdown
Owner

Bun, at some point, broke the way that imports worked for the bot - however my other bots work fine with the same codebase so idk anymore.

Anyway, this resolves #219 i think?

Copilot AI review requested due to automatic review settings June 19, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures how the Discord client and event handlers are imported/initialized to avoid async/circular-import timing issues (notably under Bun), while also standardizing command replies via a shared embed helper and adjusting YouTube upload-type detection.

Changes:

  • Introduces a shared src/client.ts and updates imports across events/utils/commands to use it instead of importing from index/root.
  • Ensures events are imported/registered before client.login() so interaction handlers are attached in time.
  • Refactors command replies to use a reusable quick-embed helper and updates YouTube upload classification to use duration + playlist checks.

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils/youtube/sendLatestUploads.ts Updates client import path to the new shared client module.
src/utils/youtube/fetchLatestUploads.ts Adds duration-based classification + new YouTube Videos API response typing.
src/utils/twitch/checkIfStreamerIsLive.ts Updates client import path to the new shared client module.
src/utils/quickEmbed.ts Adds reusable embed builder + interaction reply helper utilities.
src/utils/discord/updateGuildsOnStartup.ts Updates client import path to the new shared client module.
src/utils/cronJobs.ts Updates client import path to the new shared client module.
src/types/youtube.d.ts Adds typing for YouTube Videos API contentDetails response.
src/index.ts Imports events before login and uses the shared client module.
src/events/ready.ts Updates client import path to the new shared client module.
src/events/guildDelete.ts Updates client import path to the new shared client module.
src/events/guildCreate.ts Updates client import path to the new shared client module.
src/events/commandHandlerAuto.ts Updates client import path to the new shared client module.
src/events/commandHandler.ts Updates client import path to the new shared client module.
src/commands.ts Switches many replies to replyWithQuickEmbed and updates client import path.
src/client.ts New shared Discord Client instance module.
package.json Updates start script and dependency versions/formatting.
bun.lock Lockfile updates reflecting dependency version changes.
Comments suppressed due to low confidence (1)

src/utils/youtube/fetchLatestUploads.ts:195

  • shortVideoId.videoId and/or streamVideoId.videoId may be null (API error/empty playlist). The current logic will fall through and classify the upload as a regular video, which can update the DB with the wrong contentType and cause missed notifications for shorts/streams. Guard against null results and skip updating when both lookups fail.
                    const [shortVideoId, streamVideoId] = await Promise.all([
                        getSinglePlaylistAndReturnVideoData(
                            channelId,
                            PlaylistType.Short,
                        ),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +177 to +181
const streamVideoId =
await getSinglePlaylistAndReturnVideoData(
channelId,
PlaylistType.Stream,
);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk, works as intended when i run it, gotta check in a few days

Comment thread src/commands.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@GalvinPython GalvinPython merged commit 576a415 into main Jun 19, 2026
2 checks passed
@GalvinPython GalvinPython deleted the chore/2.0.1 branch June 19, 2026 13:28
@github-project-automation github-project-automation Bot moved this to Done in Feedr Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

The bot is online but commands not working

2 participants