Live Radio stations and Youtube url to mp3#352
Live Radio stations and Youtube url to mp3#352gaurvviii wants to merge 1 commit intoZerioDev:masterfrom
Conversation
|
Looks great overall !
|
| const { EmbedBuilder } = require('discord.js'); | ||
| const { Translate } = require('../process_tools'); | ||
|
|
||
| module.exports = async ({ client, inter }) => { |
| const { Translate } = require('../process_tools'); | ||
| const { stopRadio } = require('../utils/radioPlayer'); | ||
|
|
||
| module.exports = async ({ client, inter }) => { |
| 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.
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'); |
|
|
||
| const defaultEmbed = new EmbedBuilder().setColor('#2f3136'); | ||
|
|
||
| // Set quality based on user selection |
There was a problem hiding this comment.
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(); |
| 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.
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.
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.
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.
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.
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! 🚀