mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2025-07-02 03:03:37 +00:00
Replace any types to more strict types
This commit is contained in:
@ -2,7 +2,7 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export default class {
|
||||
map: Map<any, any>;
|
||||
map: Map<string, any>;
|
||||
constructor() {
|
||||
this.map = new Map();
|
||||
this.loadData();
|
||||
@ -49,7 +49,7 @@ export default class {
|
||||
this.saveEntry(id, newData);
|
||||
}
|
||||
|
||||
loadEntry(id: any){
|
||||
loadEntry(id: string){
|
||||
try {
|
||||
const json = require(`../../../datastore/` + id + '.json');
|
||||
this.map.set(id, json);
|
||||
|
@ -7,7 +7,7 @@ export interface station {
|
||||
name: string,
|
||||
owner: string,
|
||||
logo: string,
|
||||
stream: []
|
||||
stream: any
|
||||
}
|
||||
|
||||
export default class Stations extends Array {
|
||||
@ -22,11 +22,11 @@ export default class Stations extends Array {
|
||||
logger('Stations', 'Started fetching list - ' + options.url);
|
||||
let list = await fetch(options.url)
|
||||
.then(this.checkFetchStatus)
|
||||
.then((response: { json: () => any; }) => response.json());
|
||||
.then((response: { json: () => station; }) => response.json());
|
||||
|
||||
if(list){
|
||||
this.length = 0;
|
||||
list.forEach((station: any) => {
|
||||
list.forEach((station: station) => {
|
||||
try {
|
||||
this.push(station);
|
||||
} catch (error) {
|
||||
@ -61,7 +61,7 @@ export default class Stations extends Array {
|
||||
}
|
||||
|
||||
checkFetchStatus(response: any) {
|
||||
if (response.ok) { // res.status >= 200 && res.status < 300
|
||||
if (response.ok) {
|
||||
return response;
|
||||
} else {
|
||||
throw new Error(response.status + " " + response.statusText);
|
||||
|
@ -1,6 +1,7 @@
|
||||
import logger from "../funcs/logger";
|
||||
import { createAudioPlayer, createAudioResource, NoSubscriberBehavior } from "@discordjs/voice";
|
||||
import RadioClient from "../../Client";
|
||||
import { station } from "./Stations";
|
||||
|
||||
export default class Streamer {
|
||||
map: any;
|
||||
@ -29,7 +30,7 @@ export default class Streamer {
|
||||
if(this.mode == "auto"){
|
||||
if(!client.stations) return;
|
||||
|
||||
client.stations.forEach((station: any) => {
|
||||
client.stations.forEach((station: station) => {
|
||||
this.play(station);
|
||||
});
|
||||
}
|
||||
@ -40,13 +41,13 @@ export default class Streamer {
|
||||
|
||||
let streamers = this.map.keys();
|
||||
streamers.forEach((streamer: any) => {
|
||||
if(client.stations?.findIndex((station: { name: any; }) => station.name == streamer) == -1){
|
||||
if(client.stations?.findIndex((station: station) => station.name == streamer) == -1){
|
||||
this.stop(streamer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
play(station: any) {
|
||||
play(station: station) {
|
||||
let audioPlayer = this.map.get(station.name);
|
||||
if(!audioPlayer) {
|
||||
if(this.mode == "auto"){
|
||||
@ -95,7 +96,7 @@ export default class Streamer {
|
||||
return audioPlayer;
|
||||
}
|
||||
|
||||
stop(station: any){
|
||||
stop(station: station){
|
||||
let audioPlayer = this.map.get(station.name);
|
||||
if(audioPlayer){
|
||||
logger('Streamer', station.name + " / " + "Stop");
|
||||
@ -105,7 +106,7 @@ export default class Streamer {
|
||||
this.map.delete(station.name);
|
||||
}
|
||||
|
||||
listen(station: any) {
|
||||
listen(station: station) {
|
||||
let audioPlayer = this.map.get(station.name);
|
||||
if(!audioPlayer || this.mode == "manual" && audioPlayer.subscribers.length == 0) audioPlayer = this.play(station);
|
||||
return audioPlayer;
|
||||
@ -113,7 +114,7 @@ export default class Streamer {
|
||||
|
||||
leave(client: RadioClient) {
|
||||
if(!client.stations) return;
|
||||
client.stations.forEach((station: any) => {
|
||||
client.stations.forEach((station: station) => {
|
||||
this.stop(station);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user