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

🚧 Updating Distube #157

Merged
merged 1 commit into from
Sep 6, 2024
Merged

🚧 Updating Distube #157

merged 1 commit into from
Sep 6, 2024

Conversation

Drlanderf
Copy link
Owner

@Drlanderf Drlanderf commented Sep 6, 2024

Summary by Sourcery

Refactor the music command and Distube event listeners to simplify code and improve error handling. Enhance the Distube client with additional plugins for SoundCloud, Spotify, and YouTube, and update configuration settings for improved functionality.

Enhancements:

  • Simplify the embed creation and response handling in the music command by removing redundant code and streamlining the embed setup.
  • Improve error handling in the Distube event listeners by consolidating try-catch blocks and simplifying the error messages.
  • Enhance the Distube client setup by adding plugins for SoundCloud, Spotify, and YouTube, and adjusting configuration options for better performance.

Copy link

sourcery-ai bot commented Sep 6, 2024

Reviewer's Guide by Sourcery

This pull request updates the Distube music bot implementation, focusing on code simplification, error handling improvements, and the addition of new plugins. The changes primarily affect the music command handling, event listeners, and the main bot configuration.

File-Level Changes

Change Details Files
Simplified music command handling and error responses
  • Condensed embed creation and reply logic
  • Removed redundant footer text
  • Streamlined error handling in music subcommands
src/commands/music/music.js
Refactored Distube event listeners for improved readability
  • Condensed event listener code
  • Simplified error logging
  • Removed redundant try-catch blocks
src/events/discord/client/ready.js
Updated Distube configuration and added new plugins
  • Imported SoundCloud, Spotify, and YouTube plugins
  • Modified Distube initialization with new options
  • Added emptyCooldown setting
src/index.js
Minor schema update for improved code style
  • Adjusted the formatting of the guildSchema definition
src/schemas/guild.js

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@Drlanderf Drlanderf merged commit 072e484 into release Sep 6, 2024
1 check passed
@Drlanderf Drlanderf deleted the Trying-updating-distube branch September 6, 2024 19:50
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Drlanderf - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The code cleanup is appreciated, but please review the removed error handling to ensure no critical functionality is lost.
  • Consider maintaining consistency in module imports. The switch from require() to import in index.js might cause issues if the rest of the project uses CommonJS.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

ephemeral: true,
});
embed.setDescription("Vous devez être dans un salon vocal pour utiliser cette commande.");
return interaction.reply({embeds: [embed], ephemeral: true,});
}
if (!member.voice.channelId === guild.members.me.voice.channelId) {
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Incorrect condition in voice channel check

The condition for checking if the member is in the same voice channel as the bot is incorrect. The current negation will always evaluate to a boolean, making the comparison meaningless. Consider changing it to if (member.voice.channelId !== guild.members.me.voice.channelId).

emitNewSongOnly: true,
leaveOnFinish: true,
emitAddSongWhenCreatingQueue: false,
client.distube = new Distube.default(client, {
Copy link

Choose a reason for hiding this comment

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

issue (typo): Potential typo in Distube initialization

There seems to be a typo in the Distube initialization. It should be DisTube (with a capital 'T') instead of Distube. This could lead to runtime errors if not corrected.

Comment on lines 88 to 90
if (channel)
channel.send(
`⛔ | An error encountered: ${e.toString().slice(0, 1974)}`
);
channel.send(`⛔ | An error encountered: ${e.toString().slice(0, 1974)}`);
else console.error(e);
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (channel)
channel.send(
`⛔ | An error encountered: ${e.toString().slice(0, 1974)}`
);
channel.send(`⛔ | An error encountered: ${e.toString().slice(0, 1974)}`);
else console.error(e);
if (channel) {
channel.send(`⛔ | An error encountered: ${e.toString().slice(0, 1974)}`);
} else console.error(e);


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant