Add generic live stream support (only mp3 streams atm)
This commit is contained in:
parent
2110b10539
commit
6482c1462f
38
index.js
38
index.js
|
@ -452,7 +452,7 @@ discord.on('ready', async () => {
|
|||
"default_member_permissions": 0
|
||||
},
|
||||
{
|
||||
"name": "play",
|
||||
"name": "playbcfy",
|
||||
"description": "Play the broadcastify stream",
|
||||
"options": [
|
||||
{
|
||||
|
@ -462,6 +462,18 @@ discord.on('ready', async () => {
|
|||
"required": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "play",
|
||||
"description": "Play a stream",
|
||||
"options": [
|
||||
{
|
||||
"name": "url",
|
||||
"description": "The URL of the stream to play",
|
||||
"type": 3,
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -689,13 +701,31 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
interaction.reply({ embeds: [embed] });
|
||||
break;
|
||||
|
||||
case "play": // Play broadcastify stream
|
||||
case "playbcfy": // Play broadcastify stream
|
||||
if (!config.broadcastify.enabled) return interaction.reply({ content: "Broadcastify is not enabled", ephemeral: true });
|
||||
const streamID = interaction.options.getString("id");
|
||||
streamID = interaction.options.getString("id");
|
||||
// Check if the stream ID is valid (up to 10 digit alphanumeric)
|
||||
if (!streamID.match(/^[a-zA-Z0-9]{1,10}$/)) return interaction.reply({ content: "Invalid stream ID", ephemeral: true });
|
||||
// Get the stream URL
|
||||
const url = `https://${config.broadcastify.username}:${config.broadcastify.password}@audio.broadcastify.com/${streamID}.mp3`;
|
||||
url = `https://${config.broadcastify.username}:${config.broadcastify.password}@audio.broadcastify.com/${streamID}.mp3`;
|
||||
// Get the channel
|
||||
channel = interaction.member.voice.channel;
|
||||
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
||||
// Join the channel and play the stream
|
||||
JoinChannel(channel, url, 2).then((res) => {
|
||||
if (res.status) {
|
||||
interaction.reply({ content: res.message, ephemeral: true });
|
||||
} else {
|
||||
interaction.reply({ content: `Failed to play stream: ${res.message}`, ephemeral: true });
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case "play": // Play generic stream
|
||||
// Get the URL
|
||||
url = interaction.options.getString("url");
|
||||
// Sanity check URL for funny stuff
|
||||
if (!url.match(/https?:\/\/[^\s]+/)) return interaction.reply({ content: "Invalid URL", ephemeral: true });
|
||||
// Get the channel
|
||||
channel = interaction.member.voice.channel;
|
||||
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
||||
|
|
Loading…
Reference in a new issue