-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Live Radio stations and Youtube url to mp3 #352
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
base: master
Are you sure you want to change the base?
Conversation
Looks great overall !
|
const { EmbedBuilder } = require('discord.js'); | ||
const { Translate } = require('../process_tools'); | ||
|
||
module.exports = async ({ client, inter }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused client
parameter
const { Translate } = require('../process_tools'); | ||
const { stopRadio } = require('../utils/radioPlayer'); | ||
|
||
module.exports = async ({ client, inter }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused client
parameter
let result = false; | ||
|
||
// Check if there's an active connection for this guild | ||
if (activeConnections && activeConnections.has(inter.guild.id)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use optional chaining (activeConnections?.has(inter.guild.id)
) instead (lint)
const { ApplicationCommandOptionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); | ||
const { Translate } = require('../../process_tools'); | ||
const radioStations = require('../../radioStations'); | ||
const { playRadioStation, stopRadio } = require('../../utils/radioPlayer'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused stopRadio
import
|
||
const defaultEmbed = new EmbedBuilder().setColor('#2f3136'); | ||
|
||
// Set quality based on user selection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why base quality off of volume ? Aren't these 2 different things ?
const activeConnections = new Map(); | ||
|
||
// Cache for converted URLs to avoid redundant conversions | ||
const convertedUrlCache = new Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused
player.on(AudioPlayerStatus.Idle, () => { | ||
console.log('Radio stream ended or errored, attempting to reconnect...'); | ||
// Try to restart the stream after a brief delay | ||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During this loop, user is never informed of what is going on. The only sign is the log in the console, which the user doesn't see.
// First request to get the conversion started | ||
const response = await axios.get(`https://cnvmp3.com/v23/api/single/mp3/${videoId}`); | ||
|
||
if (!response.data || !response.data.id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional chain would be better
// Second request to get the download URL | ||
const statusResponse = await axios.get(`https://cnvmp3.com/v23/api/mp3/${conversionId}`); | ||
|
||
if (!statusResponse.data || !statusResponse.data.url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here; optional chain
const { useMainPlayer, QueryType } = require('discord-player'); | ||
|
||
// Store active YouTube connections to manage them | ||
const activeYoutubeConnections = new Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use discord-player
to stream the music, then you can just stay with queues and the hooks (useQueue
)
|
||
// Create an audio resource from the stream | ||
const resource = createAudioResource(streamResponse, { | ||
inputType: StreamType.Arbitrary, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be the value defined in the radioStations.js
file ?
Title: Add Live Radio Support & YouTube to MP3 Conversion
Description:
This pull request introduces two major features to the bot:
Live Radio Support – Users can now stream live radio stations directly through the bot. Added support for various radio stream URLs.
YouTube to MP3 Conversion – Users can provide a YouTube URL, and the bot will convert and play the audio. This improves accessibility for users who prefer listening without streaming the video.
Changes & Additions:
Implemented a radio command to handle live streaming links.
Added a YouTube to MP3 converter using yt-dlp for efficient audio extraction.
Updated the help command to reflect new features.
Optimized playback handling for seamless integration of new features.
Testing & Notes:
Tested multiple radio stations for compatibility.
Ensured YouTube conversion handles common formats and errors gracefully.
Verified smooth playback transitions between different audio sources.
Looking forward to feedback! 🚀