Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add soundboard #10590

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

sdanialraza
Copy link
Member

Please describe the changes this PR makes and why it should be merged:
Adds soundboard for mainlib

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

Copy link

vercel bot commented Nov 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Mar 10, 2025 1:02am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Mar 10, 2025 1:02am

@Jiralite

This comment has been minimized.

@sdanialraza sdanialraza force-pushed the feat/add-soundboard branch 2 times, most recently from f3031c1 to 55725d0 Compare February 8, 2025 14:26
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 39.12%. Comparing base (ab6a694) to head (ff64ad3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10590      +/-   ##
==========================================
- Coverage   39.15%   39.12%   -0.03%     
==========================================
  Files         244      244              
  Lines       14804    14797       -7     
  Branches     1413     1414       +1     
==========================================
- Hits         5796     5789       -7     
  Misses       8996     8996              
  Partials       12       12              
Flag Coverage Δ
proxy 64.63% <ø> (ø)
rest 87.37% <100.00%> (+0.03%) ⬆️
ws 34.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sdanialraza sdanialraza force-pushed the feat/add-soundboard branch 2 times, most recently from 830929a to 1e0fb55 Compare February 19, 2025 15:36
@sam51210

This comment was marked as off-topic.

Copy link
Contributor

@Qjuh Qjuh left a comment

Choose a reason for hiding this comment

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

Might be worth to add a get soundboardSound() to

this.soundId = data.sound_id ?? null;
which can be null if that sound_id is not found in the this.guild.soundboardSounds.cache.

async create({ emojiId, emojiName, file, name, reason, volume }) {
const resolvedFile = await resolveFile(file);

const sound = resolveBase64(resolvedFile.data, 'audio/mp3');
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this support both mp3 and oggbased on the file type, not hardcoded to mp3?

Copy link
Member

@didinele didinele Mar 4, 2025

Choose a reason for hiding this comment

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

We can try:

  1. Take it as a required parameter from the user (I wouldn't go this route)
  2. userParam ?? resolvedFile.contentType ?? lazilyLoadedMagicBytesLib()

@sdanialraza sdanialraza requested a review from Qjuh March 5, 2025 22:01
Comment on lines +55 to +73
if ('emoji_id' in data) {
/**
* The emoji id of the soundboard sound
* @type {?Snowflake}
*/
this.emojiId = data.emoji_id;
} else {
this.emojiId ??= null;
}

if ('emoji_name' in data) {
/**
* The emoji name of the soundboard sound
* @type {?string}
*/
this.emojiName = data.emoji_name;
} else {
this.emojiName ??= null;
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not saying this so you change it, but I will call out that we should think if we wanna do emojis properly and use the emoji class instead of Discord's inconsistent handling of emojis across different objects.

@sdanialraza sdanialraza requested a review from vladfrangu March 9, 2025 23:24

/**
* Send a soundboard sound to a voice channel the user is connected to.
* Fires a Voice Channel Effect Send Gateway event.
Copy link
Member

Choose a reason for hiding this comment

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

There is a tag for this: @fires

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

6 participants