mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 07:13:17 +00:00
Add more Typescript typings
This commit is contained in:
parent
b29624cba3
commit
3f1d576c44
@ -18,11 +18,10 @@ export default class Stations extends Array {
|
|||||||
async fetch(options: { url: string, show?: boolean}){
|
async fetch(options: { url: string, show?: boolean}){
|
||||||
try {
|
try {
|
||||||
logger('Stations', 'Started fetching list - ' + options.url);
|
logger('Stations', 'Started fetching list - ' + options.url);
|
||||||
let stations = await fetch(options.url)
|
let stations: station[] = await fetch(options.url)
|
||||||
.then(this.checkFetchStatus)
|
.then(this.checkFetchStatus)
|
||||||
.then((response: { json: () => station[]; }) => response.json());
|
.then((response: Response) => response.json());
|
||||||
|
|
||||||
if(!stations) return;
|
|
||||||
for (const station of stations){
|
for (const station of stations){
|
||||||
this.push(station);
|
this.push(station);
|
||||||
if(options.show) logger('Stations', station.name);
|
if(options.show) logger('Stations', station.name);
|
||||||
@ -39,7 +38,7 @@ export default class Stations extends Array {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkFetchStatus(response: any) {
|
checkFetchStatus(response: Response) {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response;
|
return response;
|
||||||
} else {
|
} else {
|
||||||
@ -48,14 +47,12 @@ export default class Stations extends Array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
search(key: string, type: string) {
|
search(key: string, type: string) {
|
||||||
if (this === null) return false;
|
if (this === null || !key || !type) return null;
|
||||||
if (!key) return false;
|
|
||||||
if (!type) return false;
|
|
||||||
|
|
||||||
if(type == "direct"){
|
if(type == "direct"){
|
||||||
let foundStation;
|
let foundStation;
|
||||||
for(const station of this){
|
for(const station of this){
|
||||||
if(station.name != key) return false;
|
if(station.name != key) return null;
|
||||||
foundStation = station;
|
foundStation = station;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +60,7 @@ export default class Stations extends Array {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
let foundStations : { station: string, name: string, probability: number }[] = [];
|
let foundStations : { station: string, name: string, probability: number }[] = [];
|
||||||
if (key == "radio") return false;
|
if (key == "radio") return null;
|
||||||
|
|
||||||
this
|
this
|
||||||
.filter(
|
.filter(
|
||||||
@ -84,7 +81,7 @@ export default class Stations extends Array {
|
|||||||
foundStations.push({ station: x, name: x.name, probability: probabilityIncrement })
|
foundStations.push({ station: x, name: x.name, probability: probabilityIncrement })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (foundStations.length === 0) return false;
|
if (foundStations.length === 0) return null;
|
||||||
for (let i = 0; i < foundStations.length; i++) {
|
for (let i = 0; i < foundStations.length; i++) {
|
||||||
for (let j = 0; j < foundStations.length; j++) {
|
for (let j = 0; j < foundStations.length; j++) {
|
||||||
if (foundStations[i] === foundStations[j] && i !== j) foundStations.splice(i, 1);
|
if (foundStations[i] === foundStations[j] && i !== j) foundStations.splice(i, 1);
|
||||||
@ -105,23 +102,23 @@ export default class Stations extends Array {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*let highestProbabilityStation : { station: string, name: string, probability: number } | string | undefined;
|
let highestProbabilityStation : { station: string, name: string, probability: number } | undefined;
|
||||||
|
let stationName = "";
|
||||||
|
|
||||||
for (let i = 0; i < foundStations.length; i++) {
|
for (let i = 0; i < foundStations.length; i++) {
|
||||||
if (
|
if (
|
||||||
!highestProbabilityStation ||
|
!highestProbabilityStation ||
|
||||||
//@ts-ignore
|
|
||||||
highestProbabilityStation.probability < foundStations[i].probability
|
highestProbabilityStation.probability < foundStations[i].probability
|
||||||
)
|
)
|
||||||
highestProbabilityStation = foundStations[i];
|
highestProbabilityStation = foundStations[i];
|
||||||
if (
|
if (
|
||||||
highestProbabilityStation &&
|
highestProbabilityStation &&
|
||||||
//@ts-ignore
|
|
||||||
highestProbabilityStation.probability === foundStations[i].probability
|
highestProbabilityStation.probability === foundStations[i].probability
|
||||||
) {
|
) {
|
||||||
highestProbabilityStation = foundStations[i].station;
|
stationName = foundStations[i].station;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return highestProbabilityStation;*/
|
return stationName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,7 @@ export interface command {
|
|||||||
description: string,
|
description: string,
|
||||||
category: string,
|
category: string,
|
||||||
options?: [],
|
options?: [],
|
||||||
execute: any
|
execute: Function
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function commands(client: RadioClient) {
|
export default async function commands(client: RadioClient) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder } from "discord.js";
|
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -16,7 +16,7 @@ export default {
|
|||||||
"%client.user.username%": client.user.username
|
"%client.user.username%": client.user.username
|
||||||
}))
|
}))
|
||||||
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
|
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.setDescription(client.messages.replace(client.messages.bugDescription, {
|
.setDescription(client.messages.replace(client.messages.bugDescription, {
|
||||||
"%client.config.supportGuild%": client.config.supportGuild
|
"%client.config.supportGuild%": client.config.supportGuild
|
||||||
}))
|
}))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder } from "discord.js";
|
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
import { command } from "../commands";
|
import { command } from "../commands";
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ export default {
|
|||||||
"%client.user.username%": client.user.username
|
"%client.user.username%": client.user.username
|
||||||
}))
|
}))
|
||||||
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
|
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.setDescription(client.messages.replace(client.messages.helpDescription, {
|
.setDescription(client.messages.replace(client.messages.helpDescription, {
|
||||||
"%commands%": commands
|
"%commands%": commands
|
||||||
}))
|
}))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder } from "discord.js";
|
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -16,7 +16,7 @@ export default {
|
|||||||
.setTitle(client.messages.replace(client.messages.inviteTitle, {
|
.setTitle(client.messages.replace(client.messages.inviteTitle, {
|
||||||
"%client.user.username%": client.user.username
|
"%client.user.username%": client.user.username
|
||||||
}))
|
}))
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.setURL("https://discord.com/api/oauth2/authorize?client_id=" + client.user.id + "&permissions=2184465408&scope=applications.commands%20bot") //View Channels, Send Messages, Embed Links, Use External Emojis, Use Slash Commands, Connect, Speak, Use Voice Activity
|
.setURL("https://discord.com/api/oauth2/authorize?client_id=" + client.user.id + "&permissions=2184465408&scope=applications.commands%20bot") //View Channels, Send Messages, Embed Links, Use External Emojis, Use Slash Commands, Connect, Speak, Use Voice Activity
|
||||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||||
.setFooter({
|
.setFooter({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
import { ButtonInteraction, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
import { station } from "../classes/Stations";
|
import { station } from "../classes/Stations";
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ export default {
|
|||||||
let embed = new EmbedBuilder()
|
let embed = new EmbedBuilder()
|
||||||
.setTitle(client.messages.listTitle)
|
.setTitle(client.messages.listTitle)
|
||||||
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["list"].replace(/[^0-9]+/g, ''))
|
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["list"].replace(/[^0-9]+/g, ''))
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.setDescription(stations)
|
.setDescription(stations)
|
||||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||||
.setFooter({
|
.setFooter({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ActionRowBuilder, APISelectMenuOption, ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuBuilder, StringSelectMenuInteraction } from "discord.js";
|
import { ActionRowBuilder, APISelectMenuOption, ButtonInteraction, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuBuilder, StringSelectMenuInteraction } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
import Streamer from "../classes/Streamer";
|
import Streamer from "../classes/Streamer";
|
||||||
import commands from "../commands";
|
import commands from "../commands";
|
||||||
@ -95,7 +95,7 @@ export default {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const menu : ActionRowBuilder<any> = new ActionRowBuilder()
|
const menu = new ActionRowBuilder<StringSelectMenuBuilder>()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new StringSelectMenuBuilder()
|
new StringSelectMenuBuilder()
|
||||||
.setCustomId('maintenance')
|
.setCustomId('maintenance')
|
||||||
@ -115,7 +115,7 @@ export default {
|
|||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(client.messages.maintenanceTitle)
|
.setTitle(client.messages.maintenanceTitle)
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.setDescription(options.find((option: APISelectMenuOption) => option.value == action)?.label || "-")
|
.setDescription(options.find((option: APISelectMenuOption) => option.value == action)?.label || "-")
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: client.messages.footerText,
|
text: client.messages.footerText,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
import { ButtonInteraction, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
import { command } from "../commands";
|
import { command } from "../commands";
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export default {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(client.messages.nowplayingTitle)
|
.setTitle(client.messages.nowplayingTitle)
|
||||||
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
|
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.setDescription(client.messages.replace(client.messages.nowplayingDescription, {
|
.setDescription(client.messages.replace(client.messages.nowplayingDescription, {
|
||||||
"%radio.station.name%": radio.station.name,
|
"%radio.station.name%": radio.station.name,
|
||||||
"%radio.station.owner%\n": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : "",
|
"%radio.station.owner%\n": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : "",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
import { ButtonInteraction, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ export default {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(client.messages.statisticsTitle)
|
.setTitle(client.messages.statisticsTitle)
|
||||||
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["statistics"].replace(/[^0-9]+/g, ''))
|
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["statistics"].replace(/[^0-9]+/g, ''))
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.setDescription(statistics)
|
.setDescription(statistics)
|
||||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||||
.setFooter({
|
.setFooter({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder } from "discord.js";
|
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -19,7 +19,7 @@ export default {
|
|||||||
"%client.user.username%": client.user.username
|
"%client.user.username%": client.user.username
|
||||||
}))
|
}))
|
||||||
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
|
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.addFields([
|
.addFields([
|
||||||
{ name: client.messages.statusField1, value: uptime },
|
{ name: client.messages.statusField1, value: uptime },
|
||||||
{ name: client.messages.statusField2, value: client.config.version },
|
{ name: client.messages.statusField2, value: client.config.version },
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
import { ButtonInteraction, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
import { command } from "../commands";
|
import { command } from "../commands";
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ export default {
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(client.user?.username || "-")
|
.setTitle(client.user?.username || "-")
|
||||||
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["stop"].replace(/[^0-9]+/g, ''))
|
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["stop"].replace(/[^0-9]+/g, ''))
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.addFields({
|
.addFields({
|
||||||
name: client.messages.nowplayingTitle,
|
name: client.messages.nowplayingTitle,
|
||||||
value: "-"
|
value: "-"
|
||||||
|
@ -14,7 +14,7 @@ export default function listStations(client: RadioClient, interaction: ButtonInt
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const menu: ActionRowBuilder<any> = new ActionRowBuilder()
|
const menu = new ActionRowBuilder<StringSelectMenuBuilder>()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new StringSelectMenuBuilder()
|
new StringSelectMenuBuilder()
|
||||||
.setCustomId('play')
|
.setCustomId('play')
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, Guild, OAuth2Guild, StringSelectMenuInteraction } from "discord.js";
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, Guild, OAuth2Guild, StringSelectMenuInteraction } from "discord.js";
|
||||||
import RadioClient from "../../Client";
|
import RadioClient from "../../Client";
|
||||||
import { station } from "../classes/Stations";
|
import { station } from "../classes/Stations";
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
|
|||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(client.user?.username || "-")
|
.setTitle(client.user?.username || "-")
|
||||||
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
|
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
|
||||||
.setColor(client.config.embedColor as ColorResolvable)
|
.setColor(client.config.embedColor)
|
||||||
.addFields({
|
.addFields({
|
||||||
name: client.messages.nowplayingTitle,
|
name: client.messages.nowplayingTitle,
|
||||||
value: client.messages.replace(client.messages.nowplayingDescription, {
|
value: client.messages.replace(client.messages.nowplayingDescription, {
|
||||||
@ -30,7 +30,7 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
|
|||||||
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
|
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
|
||||||
});
|
});
|
||||||
|
|
||||||
const buttons = new ActionRowBuilder()
|
const buttons = new ActionRowBuilder<ButtonBuilder>()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId('list')
|
.setCustomId('list')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { ColorResolvable } from "discord.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
//credentials
|
//credentials
|
||||||
@ -14,7 +16,7 @@ export default {
|
|||||||
],
|
],
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
embedColor: "#88aa00",
|
embedColor: "#88aa00" as ColorResolvable,
|
||||||
hostedBy: "[Warén Group](https://waren.io)",
|
hostedBy: "[Warén Group](https://waren.io)",
|
||||||
|
|
||||||
//Settings
|
//Settings
|
||||||
|
Loading…
Reference in New Issue
Block a user