mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-11-09 23:00:18 +00:00
commit
629bf34b4b
2
.github/workflows/codeql-analyze.yml
vendored
2
.github/workflows/codeql-analyze.yml
vendored
@ -39,7 +39,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
|
4
.github/workflows/docker-build.yml
vendored
4
.github/workflows/docker-build.yml
vendored
@ -12,9 +12,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2.9.0
|
||||
uses: docker/setup-buildx-action@v3.0.0
|
||||
id: buildx
|
||||
with:
|
||||
install: true
|
||||
|
4
.github/workflows/typescript-build.yml
vendored
4
.github/workflows/typescript-build.yml
vendored
@ -11,9 +11,9 @@ jobs:
|
||||
name: TypeScript Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: install node v16
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
- name: npm install
|
||||
|
@ -5,7 +5,7 @@
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 0.5.x | :white_check_mark: |
|
||||
| 0.4.x | :white_check_mark: |
|
||||
| 0.4.x | :x: |
|
||||
| 0.3.x | :x: |
|
||||
| 0.2.x | :x: |
|
||||
| 0.1.x | :x: |
|
||||
|
844
package-lock.json
generated
844
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
34
package.json
34
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eximiabots-radiox",
|
||||
"version": "0.5.1",
|
||||
"version": "0.5.2",
|
||||
"description": "Internet Radio to your Discord guild",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@ -18,29 +18,29 @@
|
||||
"url": "https://github.com/warengroup/eximiabots-radiox/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^1.6.3",
|
||||
"@discordjs/builders": "^1.7.0",
|
||||
"@discordjs/opus": "^0.9.0",
|
||||
"@discordjs/rest": "^1.7.1",
|
||||
"@discordjs/voice": "^0.16.0",
|
||||
"discord-api-types": "^0.37.47",
|
||||
"discord.js": "^14.11.0",
|
||||
"@discordjs/rest": "^2.2.0",
|
||||
"@discordjs/voice": "^0.16.1",
|
||||
"discord-api-types": "^0.37.63",
|
||||
"discord.js": "^14.14.1",
|
||||
"dotenv": "^16.3.1",
|
||||
"libsodium-wrappers": "^0.7.11",
|
||||
"libsodium-wrappers": "^0.7.13",
|
||||
"path": "^0.12.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.4.1",
|
||||
"@types/ws": "^8.5.5",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/parser": "^6.0.0",
|
||||
"eslint": "^8.44.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"prettier": "^3.0.0",
|
||||
"rimraf": "^5.0.1",
|
||||
"@types/node": "^20.9.4",
|
||||
"@types/ws": "^8.5.9",
|
||||
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
||||
"@typescript-eslint/parser": "^6.11.0",
|
||||
"eslint": "^8.54.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"prettier": "^3.1.0",
|
||||
"rimraf": "^5.0.5",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsc-watch": "^6.0.4",
|
||||
"typescript": "^5.1.6"
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.16.0",
|
||||
|
@ -6,6 +6,10 @@ export interface station {
|
||||
logo: string,
|
||||
stream: {
|
||||
[key: string]: string
|
||||
},
|
||||
playlist?: {
|
||||
type: "supla" | "yle",
|
||||
address: string | string
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +24,7 @@ export default class Stations extends Array {
|
||||
logger('Stations', 'Started fetching list - ' + options.url);
|
||||
let stations: station[] = await fetch(options.url)
|
||||
.then(this.checkFetchStatus)
|
||||
.then((response: Response) => response.json());
|
||||
.then((response: Response) => response.json() as Promise<station[]>);
|
||||
|
||||
for(const station of stations){
|
||||
this.push(station);
|
||||
|
@ -70,6 +70,13 @@ export default class Streamer {
|
||||
})
|
||||
.on(AudioPlayerStatus.Idle, () => {
|
||||
logger('Streamer', station.name + " / " + "Idle");
|
||||
if(this.mode == "auto"){
|
||||
const url = station.stream[station.stream.default];
|
||||
const resource = createAudioResource(url);
|
||||
audioPlayer?.play(resource);
|
||||
} else {
|
||||
this.stop(station.name);
|
||||
}
|
||||
})
|
||||
.on(AudioPlayerStatus.Paused, () => {
|
||||
logger('Streamer', station.name + " / " + "Paused");
|
||||
|
@ -16,6 +16,27 @@ 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 => {
|
||||
});
|
||||
try {
|
||||
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 = "-";
|
||||
}
|
||||
} catch(TypeError) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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 +44,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 != undefined ? "\n\n" + radio.station.track : ""
|
||||
}))
|
||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||
.setFooter({
|
||||
|
@ -10,18 +10,43 @@ 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 => {
|
||||
});
|
||||
|
||||
try {
|
||||
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 = "-";
|
||||
}
|
||||
} catch(TypeError) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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 != undefined ? "\n\n" + radio.station.track : "-"
|
||||
})
|
||||
})
|
||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||
@ -73,6 +98,71 @@ 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 => {
|
||||
});
|
||||
try {
|
||||
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 = "-";
|
||||
}
|
||||
} catch(TypeError) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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 != undefined ? "\n\n" + 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