mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 01:53: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}){
|
||||
try {
|
||||
logger('Stations', 'Started fetching list - ' + options.url);
|
||||
let stations = await fetch(options.url)
|
||||
let stations: station[] = await fetch(options.url)
|
||||
.then(this.checkFetchStatus)
|
||||
.then((response: { json: () => station[]; }) => response.json());
|
||||
.then((response: Response) => response.json());
|
||||
|
||||
if(!stations) return;
|
||||
for (const station of stations){
|
||||
this.push(station);
|
||||
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) {
|
||||
return response;
|
||||
} else {
|
||||
@ -48,14 +47,12 @@ export default class Stations extends Array {
|
||||
}
|
||||
|
||||
search(key: string, type: string) {
|
||||
if (this === null) return false;
|
||||
if (!key) return false;
|
||||
if (!type) return false;
|
||||
if (this === null || !key || !type) return null;
|
||||
|
||||
if(type == "direct"){
|
||||
let foundStation;
|
||||
for(const station of this){
|
||||
if(station.name != key) return false;
|
||||
if(station.name != key) return null;
|
||||
foundStation = station;
|
||||
}
|
||||
|
||||
@ -63,7 +60,7 @@ export default class Stations extends Array {
|
||||
} else {
|
||||
|
||||
let foundStations : { station: string, name: string, probability: number }[] = [];
|
||||
if (key == "radio") return false;
|
||||
if (key == "radio") return null;
|
||||
|
||||
this
|
||||
.filter(
|
||||
@ -84,7 +81,7 @@ export default class Stations extends Array {
|
||||
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 j = 0; j < foundStations.length; j++) {
|
||||
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++) {
|
||||
if (
|
||||
!highestProbabilityStation ||
|
||||
//@ts-ignore
|
||||
highestProbabilityStation.probability < foundStations[i].probability
|
||||
)
|
||||
highestProbabilityStation = foundStations[i];
|
||||
if (
|
||||
highestProbabilityStation &&
|
||||
//@ts-ignore
|
||||
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,
|
||||
category: string,
|
||||
options?: [],
|
||||
execute: any
|
||||
execute: Function
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
export default {
|
||||
@ -16,7 +16,7 @@ export default {
|
||||
"%client.user.username%": client.user.username
|
||||
}))
|
||||
.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, {
|
||||
"%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 { command } from "../commands";
|
||||
|
||||
@ -27,7 +27,7 @@ export default {
|
||||
"%client.user.username%": client.user.username
|
||||
}))
|
||||
.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, {
|
||||
"%commands%": commands
|
||||
}))
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
||||
import RadioClient from "../../Client";
|
||||
|
||||
export default {
|
||||
@ -16,7 +16,7 @@ export default {
|
||||
.setTitle(client.messages.replace(client.messages.inviteTitle, {
|
||||
"%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
|
||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||
.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 { station } from "../classes/Stations";
|
||||
|
||||
@ -31,7 +31,7 @@ export default {
|
||||
let embed = new EmbedBuilder()
|
||||
.setTitle(client.messages.listTitle)
|
||||
.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)
|
||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||
.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 Streamer from "../classes/Streamer";
|
||||
import commands from "../commands";
|
||||
@ -95,7 +95,7 @@ export default {
|
||||
}
|
||||
);
|
||||
|
||||
const menu : ActionRowBuilder<any> = new ActionRowBuilder()
|
||||
const menu = new ActionRowBuilder<StringSelectMenuBuilder>()
|
||||
.addComponents(
|
||||
new StringSelectMenuBuilder()
|
||||
.setCustomId('maintenance')
|
||||
@ -115,7 +115,7 @@ export default {
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(client.messages.maintenanceTitle)
|
||||
.setColor(client.config.embedColor as ColorResolvable)
|
||||
.setColor(client.config.embedColor)
|
||||
.setDescription(options.find((option: APISelectMenuOption) => option.value == action)?.label || "-")
|
||||
.setFooter({
|
||||
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 { command } from "../commands";
|
||||
|
||||
@ -19,7 +19,7 @@ export default {
|
||||
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, '')))
|
||||
.setColor(client.config.embedColor as ColorResolvable)
|
||||
.setColor(client.config.embedColor)
|
||||
.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" : "",
|
||||
|
@ -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";
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ export default {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(client.messages.statisticsTitle)
|
||||
.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)
|
||||
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
||||
.setFooter({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
||||
import RadioClient from "../../Client";
|
||||
|
||||
export default {
|
||||
@ -19,7 +19,7 @@ export default {
|
||||
"%client.user.username%": client.user.username
|
||||
}))
|
||||
.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([
|
||||
{ name: client.messages.statusField1, value: uptime },
|
||||
{ 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 { command } from "../commands";
|
||||
|
||||
@ -16,7 +16,7 @@ export default {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(client.user?.username || "-")
|
||||
.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({
|
||||
name: client.messages.nowplayingTitle,
|
||||
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(
|
||||
new StringSelectMenuBuilder()
|
||||
.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 { station } from "../classes/Stations";
|
||||
|
||||
@ -13,7 +13,7 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
|
||||
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 as ColorResolvable)
|
||||
.setColor(client.config.embedColor)
|
||||
.addFields({
|
||||
name: client.messages.nowplayingTitle,
|
||||
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, '')
|
||||
});
|
||||
|
||||
const buttons = new ActionRowBuilder()
|
||||
const buttons = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('list')
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { ColorResolvable } from "discord.js";
|
||||
|
||||
export default {
|
||||
|
||||
//credentials
|
||||
@ -14,7 +16,7 @@ export default {
|
||||
],
|
||||
|
||||
//misc
|
||||
embedColor: "#88aa00",
|
||||
embedColor: "#88aa00" as ColorResolvable,
|
||||
hostedBy: "[Warén Group](https://waren.io)",
|
||||
|
||||
//Settings
|
||||
|
Loading…
Reference in New Issue
Block a user