mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 01:53:17 +00:00
Add track info from Supla playlist
This commit is contained in:
parent
ccb477faa9
commit
c35a0801fd
@ -16,6 +16,24 @@ export default {
|
||||
radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime);
|
||||
const completed = (radio.playTime);
|
||||
|
||||
if(radio.station?.playlist?.type == "supla" || radio.station?.playlist?.type == "yle"){
|
||||
let playlist: any = await fetch(radio.station.playlist.address)
|
||||
.then((response: Response) => response.json())
|
||||
.catch(error => {
|
||||
});
|
||||
|
||||
switch(radio.station?.playlist.type){
|
||||
case "supla":
|
||||
radio.station.track = "__" + playlist.items[0].artist + "__" + "\n" + playlist.items[0].song;
|
||||
break;
|
||||
case "yle":
|
||||
radio.station.track = "-";
|
||||
break;
|
||||
default:
|
||||
radio.station.track = "-";
|
||||
}
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(client.messages.nowplayingTitle)
|
||||
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
|
||||
@ -23,7 +41,8 @@ export default {
|
||||
.setDescription(client.messages.replace(client.messages.nowplayingDescription, {
|
||||
"%radio.station.name%": radio.station.name,
|
||||
"%radio.station.owner%\n": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : "",
|
||||
"%client.funcs.msToTime(completed)%": client.funcs.msToTime(completed)
|
||||
"%client.funcs.msToTime(completed)%": client.funcs.msToTime(completed),
|
||||
"\n\n%radio.station.track%": radio.station.track != "-" ? "\n\n" + radio.station.track : ""
|
||||
}))
|
||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||
.setFooter({
|
||||
|
@ -10,18 +10,39 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
|
||||
radio.connection.subscribe(audioPlayer);
|
||||
client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name);
|
||||
|
||||
if(radio.station?.playlist?.type == "supla" || radio.station?.playlist?.type == "yle"){
|
||||
let playlist: any = await fetch(radio.station.playlist.address)
|
||||
.then((response: Response) => response.json())
|
||||
.catch(error => {
|
||||
});
|
||||
|
||||
switch(radio.station?.playlist.type){
|
||||
case "supla":
|
||||
radio.station.track = "__" + playlist.items[0].artist + "__" + "\n" + playlist.items[0].song;
|
||||
break;
|
||||
case "yle":
|
||||
radio.station.track = "-";
|
||||
break;
|
||||
default:
|
||||
radio.station.track = "-";
|
||||
}
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(client.user?.username || "-")
|
||||
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
|
||||
.setColor(client.config.embedColor)
|
||||
.addFields({
|
||||
name: client.messages.nowplayingTitle,
|
||||
value: client.messages.replace(client.messages.nowplayingDescription, {
|
||||
name: client.messages.playTitle1,
|
||||
value: client.messages.replace(client.messages.playDescription1, {
|
||||
"%radio.station.name%": radio.station.name,
|
||||
"%radio.station.owner%\n": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : "",
|
||||
"%client.funcs.msToTime(completed)%": "",
|
||||
"**": "",
|
||||
"**:2": ""
|
||||
"%radio.station.owner%": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : ""
|
||||
})
|
||||
},
|
||||
{
|
||||
name: client.messages.playTitle2,
|
||||
value: client.messages.replace(client.messages.playDescription2, {
|
||||
"%radio.station.track%": radio.station.track
|
||||
})
|
||||
})
|
||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||
@ -73,6 +94,68 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(async function(){
|
||||
let changed = false;
|
||||
|
||||
if(radio.station?.playlist?.type == "supla" || radio.station?.playlist?.type == "yle"){
|
||||
let playlist: any = await fetch(radio.station.playlist.address)
|
||||
.then((response: Response) => response.json())
|
||||
.catch(error => {
|
||||
});
|
||||
|
||||
switch(radio.station?.playlist.type){
|
||||
case "supla":
|
||||
if(radio.station.track != playlist.items[0].artist + "\n" + playlist.items[0].song){
|
||||
changed = true;
|
||||
radio.station.track = "__" + playlist.items[0].artist + "__" + "\n" + playlist.items[0].song;
|
||||
}
|
||||
break;
|
||||
case "yle":
|
||||
radio.station.track = "-";
|
||||
break;
|
||||
default:
|
||||
radio.station.track = "-";
|
||||
}
|
||||
}
|
||||
|
||||
if(changed == true){
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(client.user?.username || "-")
|
||||
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
|
||||
.setColor(client.config.embedColor)
|
||||
.addFields({
|
||||
name: client.messages.playTitle1,
|
||||
value: client.messages.replace(client.messages.playDescription1, {
|
||||
"%radio.station.name%": radio.station.name,
|
||||
"%radio.station.owner%": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : ""
|
||||
})
|
||||
},
|
||||
{
|
||||
name: client.messages.playTitle2,
|
||||
value: client.messages.replace(client.messages.playDescription2, {
|
||||
"%radio.station.track%": radio.station.track
|
||||
})
|
||||
})
|
||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||
.setFooter({
|
||||
text: client.messages.footerText,
|
||||
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
|
||||
});
|
||||
|
||||
|
||||
if(!radio.message){
|
||||
radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] });
|
||||
} else {
|
||||
if(radio.textChannel.id == radio.message.channel.id){
|
||||
radio.message.edit({ embeds: [embed], components: [buttons] });
|
||||
} else {
|
||||
radio.message?.delete();
|
||||
radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] });
|
||||
}
|
||||
}
|
||||
}
|
||||
},15000);
|
||||
|
||||
interaction?.reply({
|
||||
content: client.messages.emojis["play"] + client.messages.replace(client.messages.play, {
|
||||
"%radio.station.name%": radio.station.name
|
||||
|
@ -22,8 +22,12 @@ export const messages = {
|
||||
helpDescription: "%commands%",
|
||||
inviteTitle: "Invite %client.user.username% to your Discord server!",
|
||||
listTitle: "Radio Stations",
|
||||
playTitle1: ":radio: Channel",
|
||||
playDescription1: "__%radio.station.name%__" + "\n" + "%radio.station.owner%",
|
||||
playTitle2: ":musical_note: Track",
|
||||
playDescription2: "%radio.station.track%",
|
||||
nowplayingTitle: "Now Playing",
|
||||
nowplayingDescription: "**%radio.station.name%**" + "\n" + "%radio.station.owner%" + "\n" + "%client.funcs.msToTime(completed)%",
|
||||
nowplayingDescription: "**%radio.station.name%**" + "\n" + "%radio.station.owner%" + "\n" + "%client.funcs.msToTime(completed)%" + "\n\n" + "%radio.station.track%",
|
||||
noVoiceChannel: "You need to be in a voice channel to play radio!",
|
||||
noQuery: "You need to use a number or search for a supported station!",
|
||||
noPermsConnect: "I cannot connect to your voice channel.",
|
||||
|
Loading…
Reference in New Issue
Block a user