Merge pull request #900 from warengroup/develop

Version 0.5.3
This commit is contained in:
Christer Warén 2023-11-29 14:50:02 +02:00 committed by GitHub
commit c38f68f8d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 246 additions and 225 deletions

120
package-lock.json generated
View File

@ -1,29 +1,29 @@
{ {
"name": "eximiabots-radiox", "name": "eximiabots-radiox",
"version": "0.5.2", "version": "0.5.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "eximiabots-radiox", "name": "eximiabots-radiox",
"version": "0.5.2", "version": "0.5.3",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@discordjs/builders": "^1.7.0", "@discordjs/builders": "^1.7.0",
"@discordjs/opus": "^0.9.0", "@discordjs/opus": "^0.9.0",
"@discordjs/rest": "^2.2.0", "@discordjs/rest": "^2.2.0",
"@discordjs/voice": "^0.16.1", "@discordjs/voice": "^0.16.1",
"discord-api-types": "^0.37.63", "discord-api-types": "^0.37.65",
"discord.js": "^14.14.1", "discord.js": "^14.14.1",
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"libsodium-wrappers": "^0.7.13", "libsodium-wrappers": "^0.7.13",
"path": "^0.12.7" "path": "^0.12.7"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.9.4", "@types/node": "^20.10.0",
"@types/ws": "^8.5.9", "@types/ws": "^8.5.9",
"@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.11.0", "@typescript-eslint/parser": "^6.13.1",
"eslint": "^8.54.0", "eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1", "eslint-plugin-prettier": "^5.0.1",
@ -562,9 +562,9 @@
"dev": true "dev": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.9.4", "version": "20.10.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.4.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.0.tgz",
"integrity": "sha512-wmyg8HUhcn6ACjsn8oKYjkN/zUzQeNtMy44weTJSM6p4MMzEOuKbA3OjJ267uPCOW7Xex9dyrNTful8XTQYoDA==", "integrity": "sha512-D0WfRmU9TQ8I9PFx9Yc+EBHw+vSpIub4IDvQivcp26PtPrdMGAq5SDcpXEo/epqa/DXotVpekHiLNTg3iaKXBQ==",
"dependencies": { "dependencies": {
"undici-types": "~5.26.4" "undici-types": "~5.26.4"
} }
@ -584,16 +584,16 @@
} }
}, },
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "6.12.0", "version": "6.13.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.1.tgz",
"integrity": "sha512-XOpZ3IyJUIV1b15M7HVOpgQxPPF7lGXgsfcEIu3yDxFPaf/xZKt7s9QO/pbk7vpWQyVulpJbu4E5LwpZiQo4kA==", "integrity": "sha512-5bQDGkXaxD46bPvQt08BUz9YSaO4S0fB1LB5JHQuXTfkGPI3+UUeS387C/e9jRie5GqT8u5kFTrMvAjtX4O5kA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/regexpp": "^4.5.1", "@eslint-community/regexpp": "^4.5.1",
"@typescript-eslint/scope-manager": "6.12.0", "@typescript-eslint/scope-manager": "6.13.1",
"@typescript-eslint/type-utils": "6.12.0", "@typescript-eslint/type-utils": "6.13.1",
"@typescript-eslint/utils": "6.12.0", "@typescript-eslint/utils": "6.13.1",
"@typescript-eslint/visitor-keys": "6.12.0", "@typescript-eslint/visitor-keys": "6.13.1",
"debug": "^4.3.4", "debug": "^4.3.4",
"graphemer": "^1.4.0", "graphemer": "^1.4.0",
"ignore": "^5.2.4", "ignore": "^5.2.4",
@ -619,15 +619,15 @@
} }
}, },
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "6.12.0", "version": "6.13.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.13.1.tgz",
"integrity": "sha512-s8/jNFPKPNRmXEnNXfuo1gemBdVmpQsK1pcu+QIvuNJuhFzGrpD7WjOcvDc/+uEdfzSYpNu7U/+MmbScjoQ6vg==", "integrity": "sha512-fs2XOhWCzRhqMmQf0eicLa/CWSaYss2feXsy7xBD/pLyWke/jCIVc2s1ikEAtSW7ina1HNhv7kONoEfVNEcdDQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "6.12.0", "@typescript-eslint/scope-manager": "6.13.1",
"@typescript-eslint/types": "6.12.0", "@typescript-eslint/types": "6.13.1",
"@typescript-eslint/typescript-estree": "6.12.0", "@typescript-eslint/typescript-estree": "6.13.1",
"@typescript-eslint/visitor-keys": "6.12.0", "@typescript-eslint/visitor-keys": "6.13.1",
"debug": "^4.3.4" "debug": "^4.3.4"
}, },
"engines": { "engines": {
@ -647,13 +647,13 @@
} }
}, },
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "6.12.0", "version": "6.13.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.13.1.tgz",
"integrity": "sha512-5gUvjg+XdSj8pcetdL9eXJzQNTl3RD7LgUiYTl8Aabdi8hFkaGSYnaS6BLc0BGNaDH+tVzVwmKtWvu0jLgWVbw==", "integrity": "sha512-BW0kJ7ceiKi56GbT2KKzZzN+nDxzQK2DS6x0PiSMPjciPgd/JRQGMibyaN2cPt2cAvuoH0oNvn2fwonHI+4QUQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "6.12.0", "@typescript-eslint/types": "6.13.1",
"@typescript-eslint/visitor-keys": "6.12.0" "@typescript-eslint/visitor-keys": "6.13.1"
}, },
"engines": { "engines": {
"node": "^16.0.0 || >=18.0.0" "node": "^16.0.0 || >=18.0.0"
@ -664,13 +664,13 @@
} }
}, },
"node_modules/@typescript-eslint/type-utils": { "node_modules/@typescript-eslint/type-utils": {
"version": "6.12.0", "version": "6.13.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.13.1.tgz",
"integrity": "sha512-WWmRXxhm1X8Wlquj+MhsAG4dU/Blvf1xDgGaYCzfvStP2NwPQh6KBvCDbiOEvaE0filhranjIlK/2fSTVwtBng==", "integrity": "sha512-A2qPlgpxx2v//3meMqQyB1qqTg1h1dJvzca7TugM3Yc2USDY+fsRBiojAEo92HO7f5hW5mjAUF6qobOPzlBCBQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/typescript-estree": "6.12.0", "@typescript-eslint/typescript-estree": "6.13.1",
"@typescript-eslint/utils": "6.12.0", "@typescript-eslint/utils": "6.13.1",
"debug": "^4.3.4", "debug": "^4.3.4",
"ts-api-utils": "^1.0.1" "ts-api-utils": "^1.0.1"
}, },
@ -691,9 +691,9 @@
} }
}, },
"node_modules/@typescript-eslint/types": { "node_modules/@typescript-eslint/types": {
"version": "6.12.0", "version": "6.13.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.13.1.tgz",
"integrity": "sha512-MA16p/+WxM5JG/F3RTpRIcuOghWO30//VEOvzubM8zuOOBYXsP+IfjoCXXiIfy2Ta8FRh9+IO9QLlaFQUU+10Q==", "integrity": "sha512-gjeEskSmiEKKFIbnhDXUyiqVma1gRCQNbVZ1C8q7Zjcxh3WZMbzWVfGE9rHfWd1msQtPS0BVD9Jz9jded44eKg==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "^16.0.0 || >=18.0.0" "node": "^16.0.0 || >=18.0.0"
@ -704,13 +704,13 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree": { "node_modules/@typescript-eslint/typescript-estree": {
"version": "6.12.0", "version": "6.13.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.13.1.tgz",
"integrity": "sha512-vw9E2P9+3UUWzhgjyyVczLWxZ3GuQNT7QpnIY3o5OMeLO/c8oHljGc8ZpryBMIyympiAAaKgw9e5Hl9dCWFOYw==", "integrity": "sha512-sBLQsvOC0Q7LGcUHO5qpG1HxRgePbT6wwqOiGLpR8uOJvPJbfs0mW3jPA3ujsDvfiVwVlWUDESNXv44KtINkUQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "6.12.0", "@typescript-eslint/types": "6.13.1",
"@typescript-eslint/visitor-keys": "6.12.0", "@typescript-eslint/visitor-keys": "6.13.1",
"debug": "^4.3.4", "debug": "^4.3.4",
"globby": "^11.1.0", "globby": "^11.1.0",
"is-glob": "^4.0.3", "is-glob": "^4.0.3",
@ -731,17 +731,17 @@
} }
}, },
"node_modules/@typescript-eslint/utils": { "node_modules/@typescript-eslint/utils": {
"version": "6.12.0", "version": "6.13.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.13.1.tgz",
"integrity": "sha512-LywPm8h3tGEbgfyjYnu3dauZ0U7R60m+miXgKcZS8c7QALO9uWJdvNoP+duKTk2XMWc7/Q3d/QiCuLN9X6SWyQ==", "integrity": "sha512-ouPn/zVoan92JgAegesTXDB/oUp6BP1v8WpfYcqh649ejNc9Qv+B4FF2Ff626kO1xg0wWwwG48lAJ4JuesgdOw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.4.0", "@eslint-community/eslint-utils": "^4.4.0",
"@types/json-schema": "^7.0.12", "@types/json-schema": "^7.0.12",
"@types/semver": "^7.5.0", "@types/semver": "^7.5.0",
"@typescript-eslint/scope-manager": "6.12.0", "@typescript-eslint/scope-manager": "6.13.1",
"@typescript-eslint/types": "6.12.0", "@typescript-eslint/types": "6.13.1",
"@typescript-eslint/typescript-estree": "6.12.0", "@typescript-eslint/typescript-estree": "6.13.1",
"semver": "^7.5.4" "semver": "^7.5.4"
}, },
"engines": { "engines": {
@ -756,12 +756,12 @@
} }
}, },
"node_modules/@typescript-eslint/visitor-keys": { "node_modules/@typescript-eslint/visitor-keys": {
"version": "6.12.0", "version": "6.13.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.13.1.tgz",
"integrity": "sha512-rg3BizTZHF1k3ipn8gfrzDXXSFKyOEB5zxYXInQ6z0hUvmQlhaZQzK+YmHmNViMA9HzW5Q9+bPPt90bU6GQwyw==", "integrity": "sha512-NDhQUy2tg6XGNBGDRm1XybOHSia8mcXmlbKWoQP+nm1BIIMxa55shyJfZkHpEBN62KNPLrocSM2PdPcaLgDKMQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "6.12.0", "@typescript-eslint/types": "6.13.1",
"eslint-visitor-keys": "^3.4.1" "eslint-visitor-keys": "^3.4.1"
}, },
"engines": { "engines": {
@ -916,9 +916,9 @@
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
}, },
"node_modules/big-integer": { "node_modules/big-integer": {
"version": "1.6.51", "version": "1.6.52",
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz", "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz",
"integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==", "integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=0.6" "node": ">=0.6"
@ -1164,9 +1164,9 @@
} }
}, },
"node_modules/discord-api-types": { "node_modules/discord-api-types": {
"version": "0.37.64", "version": "0.37.65",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.64.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.65.tgz",
"integrity": "sha512-9aS+QuoNj+4e9d5uDKfds1DCpQLYn/mHx+M8OFHZ/ZZJVadZJEo275uBOaSsw5KGYGsZ4hxMzlOkIxnWirgqKA==" "integrity": "sha512-CQHW3Nu04LEHIj1Xps/sfGhTdrowilxnek2tirpLhwvrmgmLr1C6A+4JFLs+0kJMH2IX2QgDyA9GfNehqN+xPQ=="
}, },
"node_modules/discord.js": { "node_modules/discord.js": {
"version": "14.14.1", "version": "14.14.1",
@ -2155,9 +2155,9 @@
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==" "integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw=="
}, },
"node_modules/lru-cache": { "node_modules/lru-cache": {
"version": "10.0.3", "version": "10.1.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.3.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz",
"integrity": "sha512-B7gr+F6MkqB3uzINHXNctGieGsRTMwIBgxkp0yq/5BwcuDzD4A8wQpHQW6vDAm1uKSLQghmRdD9sKqf2vJ1cEg==", "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "14 || >=16.14" "node": "14 || >=16.14"

View File

@ -1,6 +1,6 @@
{ {
"name": "eximiabots-radiox", "name": "eximiabots-radiox",
"version": "0.5.2", "version": "0.5.3",
"description": "Internet Radio to your Discord guild", "description": "Internet Radio to your Discord guild",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -22,17 +22,17 @@
"@discordjs/opus": "^0.9.0", "@discordjs/opus": "^0.9.0",
"@discordjs/rest": "^2.2.0", "@discordjs/rest": "^2.2.0",
"@discordjs/voice": "^0.16.1", "@discordjs/voice": "^0.16.1",
"discord-api-types": "^0.37.63", "discord-api-types": "^0.37.65",
"discord.js": "^14.14.1", "discord.js": "^14.14.1",
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"libsodium-wrappers": "^0.7.13", "libsodium-wrappers": "^0.7.13",
"path": "^0.12.7" "path": "^0.12.7"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.9.4", "@types/node": "^20.10.0",
"@types/ws": "^8.5.9", "@types/ws": "^8.5.9",
"@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.11.0", "@typescript-eslint/parser": "^6.13.1",
"eslint": "^8.54.0", "eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1", "eslint-plugin-prettier": "^5.0.1",

View File

@ -1,19 +1,20 @@
import { Channel, Collection, GuildMember, OAuth2Guild, TextBasedChannel, VoiceBasedChannel, VoiceChannel } from "discord.js"; import { Collection, GuildMember, Message, OAuth2Guild, TextBasedChannel, VoiceBasedChannel, VoiceChannel } from "discord.js";
import { getVoiceConnection, joinVoiceChannel, VoiceConnection } from "@discordjs/voice"; import { getVoiceConnection, joinVoiceChannel, VoiceConnection } from "@discordjs/voice";
import RadioClient from "../../Client"; import RadioClient from "../../Client";
import { station } from "./Stations"; import { station } from "./Stations";
import { datastore } from "./Datastore"; import { datastore } from "./Datastore";
export interface radio { export interface radio {
textChannel: Channel | TextBasedChannel | undefined | null, textChannel: TextBasedChannel | undefined | null,
voiceChannel: Channel | VoiceBasedChannel | undefined, voiceChannel: VoiceBasedChannel | undefined,
connection: VoiceConnection | null, connection: VoiceConnection | null,
message: null, message: Message | null,
station: station, station: station,
datastore?: datastore, datastore?: datastore,
currentTime?: number, currentTime?: number,
startTime: number, startTime: number,
playTime?: number, playTime?: number,
guild?: any
} }
export interface state { export interface state {
@ -28,7 +29,7 @@ export interface state {
} }
} }
export default class Radio extends Map { export default class Radio extends Map<string, radio> {
constructor() { constructor() {
super(); super();
@ -75,8 +76,8 @@ export default class Radio extends Map {
let date = new Date(); let date = new Date();
const construct: radio = { const construct: radio = {
textChannel: client.channels.cache.get(state.channels.text), textChannel: client.channels.cache.get(state.channels.text) as TextBasedChannel,
voiceChannel: client.channels.cache.get(state.channels.voice), voiceChannel: client.channels.cache.get(state.channels.voice) as VoiceBasedChannel,
connection: null, connection: null,
message: null, message: null,
station: station, station: station,

View File

@ -8,9 +8,10 @@ export interface station {
[key: string]: string [key: string]: string
}, },
playlist?: { playlist?: {
type: "supla" | "yle", type: "radioplay" | "supla" | "yle",
address: string | string address: string | string
} }
track?: string;
} }
export default class Stations extends Array { export default class Stations extends Array {

View File

@ -6,7 +6,6 @@ import invite from "./commands/invite";
import list from "./commands/list"; import list from "./commands/list";
import maintenance from "./commands/maintenance"; import maintenance from "./commands/maintenance";
import next from "./commands/next"; import next from "./commands/next";
import nowplaying from "./commands/nowplaying";
import play from "./commands/play"; import play from "./commands/play";
import prev from "./commands/prev"; import prev from "./commands/prev";
import statistics from "./commands/statistics"; import statistics from "./commands/statistics";
@ -22,7 +21,7 @@ export interface command {
} }
export default async function commands(client: RadioClient) { export default async function commands(client: RadioClient) {
const commands : command[] = [ bug, help, invite, list, maintenance, next, nowplaying, play, prev, statistics, status, stop ]; const commands : command[] = [ bug, help, invite, list, maintenance, next, play, prev, statistics, status, stop ];
for(const command of commands){ for(const command of commands){
client.commands.set(command.name, command); client.commands.set(command.name, command);

View File

@ -1,10 +1,13 @@
import { ButtonInteraction, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js"; import { ApplicationCommandOptionType, 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";
export default { export default {
name: 'list', name: 'list',
description: 'List radio stations', description: 'List stations',
options: [
{ type: ApplicationCommandOptionType.String, name: "query", description: "Select list", choices: [{"name": "1", "value": "1"},{"name": "2", "value": "2"}], required: false}
],
category: 'radio', category: 'radio',
execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient) { execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient) {
@ -15,6 +18,20 @@ export default {
}); });
} }
if(!interaction.guild) return;
let query: string | null = null;
if(interaction.isChatInputCommand()){
query = interaction.options?.getString("query");
}
if(interaction.isStringSelectMenu()){
query = interaction.values?.[0];
}
if(!query) query = "1";
if(!client.stations) { if(!client.stations) {
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
@ -24,10 +41,10 @@ export default {
}); });
} }
const radio = client.radio?.get(interaction.guild?.id); const radio = client.radio?.get(interaction.guild.id);
if(radio && !client.config.maintenanceMode){ if(radio && !client.config.maintenanceMode){
client.funcs.listStations(client, interaction); client.funcs.listStations(client, interaction, query);
} else { } else {
let stations = `${client.stations.map((s: station) => `**#** ${s.name}`).join('\n')}` let stations = `${client.stations.map((s: station) => `**#** ${s.name}`).join('\n')}`
const hashs = stations.split('**#**').length; const hashs = stations.split('**#**').length;

View File

@ -183,7 +183,7 @@ export default {
client.user?.setStatus('idle'); client.user?.setStatus('idle');
client.radio?.save(client); client.radio?.save(client);
setInterval(() => { let timer : NodeJS.Timeout = setInterval(() => {
if(client.radio?.size == 0 && client.config.streamerMode == "manual" && client.config.maintenanceMode){ if(client.radio?.size == 0 && client.config.streamerMode == "manual" && client.config.maintenanceMode){
client.streamer?.leave(client); client.streamer?.leave(client);
client.streamer = new Streamer(); client.streamer = new Streamer();
@ -195,9 +195,9 @@ export default {
} }
if(!client.config.maintenanceMode){ if(!client.config.maintenanceMode){
clearInterval(undefined); clearInterval(timer);
} }
}, 500); }, 1000);
break; break;
case "11": case "11":
@ -207,7 +207,7 @@ export default {
client.user?.setStatus('idle'); client.user?.setStatus('idle');
client.radio?.save(client); client.radio?.save(client);
setInterval(() => { let timer2 : NodeJS.Timeout = setInterval(() => {
if(client.radio?.size == 0 && client.config.streamerMode == "auto" && client.config.maintenanceMode){ if(client.radio?.size == 0 && client.config.streamerMode == "auto" && client.config.maintenanceMode){
client.streamer?.leave(client); client.streamer?.leave(client);
client.streamer = new Streamer(); client.streamer = new Streamer();
@ -219,9 +219,9 @@ export default {
} }
if(!client.config.maintenanceMode){ if(!client.config.maintenanceMode){
clearInterval(undefined); clearInterval(timer2);
} }
}, 500); }, 1000);
break; break;
default: default:

View File

@ -9,7 +9,9 @@ export default {
category: 'radio', category: 'radio',
async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) { async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) {
if (client.funcs.check(client, interaction, command)) { if (client.funcs.check(client, interaction, command)) {
if(!interaction.guild) return;
const radio = client.radio?.get(interaction.guild?.id); const radio = client.radio?.get(interaction.guild?.id);
if(!radio) return;
if(client.config.maintenanceMode){ if(client.config.maintenanceMode){
return interaction.reply({ return interaction.reply({

View File

@ -1,62 +0,0 @@
import { ButtonInteraction, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client";
import { command } from "../commands";
export default {
name: 'nowplaying',
description: 'Current Radio Station',
category: 'radio',
async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) {
if(client.funcs.check(client, interaction, command)) {
const radio = client.radio?.get(interaction.guild?.id);
let date = new Date();
radio.currentTime = date.getTime();
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, '')))
.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" : "",
"%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({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({
embeds: [embed],
ephemeral: true
});
}
}
};

View File

@ -13,6 +13,8 @@ export default {
category: "radio", category: "radio",
async execute(interaction: ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient) { async execute(interaction: ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient) {
if(!interaction.guild) return;
if(client.config.maintenanceMode){ if(client.config.maintenanceMode){
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance, content: client.messages.emojis["error"] + client.messages.maintenance,
@ -40,10 +42,10 @@ export default {
} }
if(!query){ if(!query){
return client.funcs.listStations(client, interaction); return client.funcs.listStations(client, interaction, "1");
} }
const radio = client.radio?.get(interaction.guild?.id); const radio = client.radio?.get(interaction.guild.id);
if(!(interaction.member instanceof GuildMember)) return; if(!(interaction.member instanceof GuildMember)) return;
const voiceChannel = interaction.member?.voice.channel; const voiceChannel = interaction.member?.voice.channel;

View File

@ -9,7 +9,9 @@ export default {
category: 'radio', category: 'radio',
async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) { async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) {
if (client.funcs.check(client, interaction, command)) { if (client.funcs.check(client, interaction, command)) {
if(!interaction.guild) return;
const radio = client.radio?.get(interaction.guild?.id); const radio = client.radio?.get(interaction.guild?.id);
if(!radio) return;
if(client.config.maintenanceMode){ if(client.config.maintenanceMode){
return interaction.reply({ return interaction.reply({

View File

@ -8,7 +8,9 @@ export default {
category: 'radio', category: 'radio',
async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) { async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) {
if (client.funcs.check(client, interaction, command)) { if (client.funcs.check(client, interaction, command)) {
if(!interaction.guild) return;
const radio = client.radio?.get(interaction.guild?.id); const radio = client.radio?.get(interaction.guild?.id);
if(!radio) return;
client.statistics?.update(client, interaction.guild, radio); client.statistics?.update(client, interaction.guild, radio);
radio.connection?.destroy(); radio.connection?.destroy();
client.funcs.logger('Radio', interaction.guild?.id + " / " + 'Stop'); client.funcs.logger('Radio', interaction.guild?.id + " / " + 'Stop');
@ -18,7 +20,7 @@ export default {
.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) .setColor(client.config.embedColor)
.addFields({ .addFields({
name: client.messages.nowplayingTitle, name: client.messages.playTitle1,
value: "-" value: "-"
}) })
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
@ -28,9 +30,9 @@ export default {
}); });
if(!radio.message){ if(!radio.message){
radio.message = radio.textChannel.send({ embeds: [embed], components: [] }); radio.message = await radio.textChannel?.send({ embeds: [embed], components: [] }) ?? null;
} else { } else {
if(radio.textChannel.id == radio.message.channel.id){ if(radio.textChannel?.id == radio.message.channel.id){
radio.message.edit({ embeds: [embed], components: [] }); radio.message.edit({ embeds: [embed], components: [] });
} else { } else {
radio.message?.delete(); radio.message?.delete();
@ -41,7 +43,7 @@ export default {
await radio.message?.delete(); await radio.message?.delete();
}, 5000); }, 5000);
client.radio?.delete(interaction.guild?.id); client.radio?.delete(interaction.guild.id);
interaction.reply({ interaction.reply({
content: client.messages.emojis["stop"] + client.messages.stop, content: client.messages.emojis["stop"] + client.messages.stop,

View File

@ -53,7 +53,7 @@ export default async function voiceStateUpdate(client: RadioClient, oldState: Vo
if ((oldState.channel.members.filter(member => !member.user.bot).size === 0 && oldState.channel === radio.voiceChannel) || change) { if ((oldState.channel.members.filter(member => !member.user.bot).size === 0 && oldState.channel === radio.voiceChannel) || change) {
setTimeout(() => { setTimeout(() => {
if (!radio || !radio.connection || !radio.connection === null) return; if (!radio || !radio.connection || !radio.connection === null) return;
if (radio.voiceChannel.members.filter((member: GuildMember) => !member.user.bot).size === 0) { if (radio.voiceChannel?.members.filter((member: GuildMember) => !member.user.bot).size === 0) {
client.statistics?.update(client, newState.guild, radio); client.statistics?.update(client, newState.guild, radio);
radio.connection?.destroy(); radio.connection?.destroy();
radio.message?.delete(); radio.message?.delete();

View File

@ -4,6 +4,7 @@ import { command } from "../commands";
export default function check(client: RadioClient, interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, command: command) { export default function check(client: RadioClient, interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, command: command) {
if(!interaction.guild) return;
const radio = client.radio?.get(interaction.guild?.id); const radio = client.radio?.get(interaction.guild?.id);
if(!client.stations) { if(!client.stations) {
interaction.reply({ interaction.reply({

View File

@ -1,11 +1,12 @@
import { ActionRowBuilder, ButtonInteraction, ChatInputCommandInteraction, SelectMenuComponentOptionData, StringSelectMenuBuilder, StringSelectMenuInteraction } from "discord.js"; import { ActionRowBuilder, ButtonInteraction, ChatInputCommandInteraction, SelectMenuComponentOptionData, StringSelectMenuBuilder, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client"; import RadioClient from "../../Client";
export default function listStations(client: RadioClient, interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction){ export default function listStations(client: RadioClient, interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, offset: string){
if(!client.stations) return; if(!client.stations) return;
let options : SelectMenuComponentOptionData[] = new Array(); let options : SelectMenuComponentOptionData[] = new Array();
for (const station of client.stations){ for (const station of client.stations){
options.push({ options.push({
label: station.name, label: station.name,
@ -14,6 +15,17 @@ export default function listStations(client: RadioClient, interaction: ButtonInt
}); });
} }
switch(offset){
case "1":
options = options.slice(0,Math.round(options.length/2));
break;
case "2":
options = options.slice(Math.round(options.length/2),options.length-1);
break;
default:
options = options.slice(0,Math.round(options.length/2));
}
const menu = new ActionRowBuilder<StringSelectMenuBuilder>() const menu = new ActionRowBuilder<StringSelectMenuBuilder>()
.addComponents( .addComponents(
new StringSelectMenuBuilder() new StringSelectMenuBuilder()

View File

@ -6,29 +6,42 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
if(!guild) return; if(!guild) return;
const radio = client.radio?.get(guild.id); const radio = client.radio?.get(guild.id);
if(!radio) return;
const audioPlayer = client.streamer?.listen(station); const audioPlayer = client.streamer?.listen(station);
radio.connection.subscribe(audioPlayer); if(!audioPlayer) return;
radio.connection?.subscribe(audioPlayer);
client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name); client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name);
if(radio.station?.playlist?.type == "supla" || radio.station?.playlist?.type == "yle"){ if(radio.station.playlist){
let playlist: any = await fetch(radio.station.playlist.address) if(radio.station.playlist.type == "radioplay" || radio.station.playlist.type == "supla" || radio.station.playlist.type == "yle"){
let playlist: any = await fetch(radio.station.playlist.address)
.then((response: Response) => response.json()) .then((response: Response) => response.json())
.catch(error => { .catch(error => {
}); });
try { radio.station.track = "-";
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) {
if(playlist){
switch(radio.station.playlist.type){
case "radioplay":
if(playlist[0] && playlist[0].stationNowPlaying && playlist[0].stationNowPlaying.nowPlayingArtist && playlist[0].stationNowPlaying.nowPlayingTrack){
radio.station.track = "__" + playlist[0].stationNowPlaying.nowPlayingArtist + "__" + "\n" + playlist[0].stationNowPlaying.nowPlayingTrack;
}
break;
case "supla":
if(playlist.items && playlist.items[0] && playlist.items[0].artist && playlist.items[0].song){
radio.station.track = "__" + playlist.items[0].artist + "__" + "\n" + playlist.items[0].song;
}
break;
case "yle":
if(playlist.data && playlist.data.performer && playlist.data.title){
radio.station.track = "__" + playlist.data.performer + "__" + "\n" + playlist.data.title;
}
break;
default:
radio.station.track = "-";
}
}
} }
} }
@ -48,7 +61,14 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
value: client.messages.replace(client.messages.playDescription2, { value: client.messages.replace(client.messages.playDescription2, {
"%radio.station.track%": radio.station.track != undefined ? "\n\n" + radio.station.track : "-" "%radio.station.track%": radio.station.track != undefined ? "\n\n" + radio.station.track : "-"
}) })
},
{
name: client.messages.playTitle3,
value: client.messages.replace(client.messages.playDescription3, {
"%client.funcs.msToTime(completed)%": "-"
})
}) })
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({ .setFooter({
text: client.messages.footerText, text: client.messages.footerText,
@ -88,80 +108,104 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
); );
if(!radio.message){ if(!radio.message){
radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] }); radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] }) ?? null;
} else { } else {
if(radio.textChannel.id == radio.message.channel.id){ if(radio.textChannel?.id == radio.message.channel.id){
radio.message.edit({ embeds: [embed], components: [buttons] }); radio.message.edit({ embeds: [embed], components: [buttons] });
} else { } else {
radio.message?.delete(); radio.message?.delete();
radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] }); radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] }) ?? null;
} }
} }
setInterval(async function(){ const oldRadio = {...radio};
let changed = false;
if(radio.station?.playlist?.type == "supla" || radio.station?.playlist?.type == "yle"){ let timer : NodeJS.Timeout = setInterval(async function(){
let playlist: any = await fetch(radio.station.playlist.address) const radio = client.radio?.get(guild.id);
if(!radio || !oldRadio || radio.station.name != oldRadio.station.name) {
return clearInterval(timer);
}
if(radio.station.playlist){
if(radio.station.playlist.type == "radioplay" || radio.station.playlist.type == "supla" || radio.station.playlist.type == "yle"){
let playlist: any = await fetch(radio.station.playlist.address)
.then((response: Response) => response.json()) .then((response: Response) => response.json())
.catch(error => { .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) {
radio.station.track = "-";
if(playlist){
switch(radio.station.playlist?.type){
case "radioplay":
if(playlist[0] && playlist[0].stationNowPlaying && playlist[0].stationNowPlaying.nowPlayingArtist && playlist[0].stationNowPlaying.nowPlayingTrack){
radio.station.track = "__" + playlist[0].stationNowPlaying.nowPlayingArtist + "__" + "\n" + playlist[0].stationNowPlaying.nowPlayingTrack;
}
break;
case "supla":
if(playlist.items && playlist.items[0] && playlist.items[0].artist && playlist.items[0].song){
radio.station.track = "__" + playlist.items[0].artist + "__" + "\n" + playlist.items[0].song;
}
break;
case "yle":
if(playlist.data && playlist.data.performer && playlist.data.title){
radio.station.track = "__" + playlist.data.performer + "__" + "\n" + playlist.data.title;
}
break;
default:
radio.station.track = "-";
}
}
} }
} }
if(changed == true){ let date = new Date();
const embed = new EmbedBuilder() radio.currentTime = date.getTime();
.setTitle(client.user?.username || "-") radio.playTime = radio.currentTime - radio.startTime;
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, ''))) const completed = (radio.playTime);
.setColor(client.config.embedColor)
.addFields({ const embed = new EmbedBuilder()
name: client.messages.playTitle1, .setTitle(client.user?.username || "-")
value: client.messages.replace(client.messages.playDescription1, { .setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
"%radio.station.name%": radio.station.name, .setColor(client.config.embedColor)
"%radio.station.owner%": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : "" .addFields({
}) name: client.messages.playTitle1,
}, value: client.messages.replace(client.messages.playDescription1, {
{ "%radio.station.name%": radio.station.name,
name: client.messages.playTitle2, "%radio.station.owner%": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : ""
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, name: client.messages.playTitle2,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '') value: client.messages.replace(client.messages.playDescription2, {
}); "%radio.station.track%": radio.station.track != undefined ? "\n\n" + radio.station.track : "-"
})
},
{
name: client.messages.playTitle3,
value: client.messages.replace(client.messages.playDescription3, {
"%client.funcs.msToTime(completed)%": client.funcs.msToTime(completed)
})
})
.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){ if(!radio.message){
radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] }); radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] }) ?? null;
} else {
if(radio.textChannel?.id == radio.message.channel.id){
radio.message?.edit({ embeds: [embed], components: [buttons] });
} else { } else {
if(radio.textChannel.id == radio.message.channel.id){ radio.message?.delete();
radio.message.edit({ embeds: [embed], components: [buttons] }); radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] }) ?? null;
} else {
radio.message?.delete();
radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] });
}
} }
} }
},15000); },2500);
interaction?.reply({ interaction?.reply({
content: client.messages.emojis["play"] + client.messages.replace(client.messages.play, { content: client.messages.emojis["play"] + client.messages.replace(client.messages.play, {

View File

@ -26,8 +26,8 @@ export const messages = {
playDescription1: "__%radio.station.name%__" + "\n" + "%radio.station.owner%", playDescription1: "__%radio.station.name%__" + "\n" + "%radio.station.owner%",
playTitle2: ":musical_note: Track", playTitle2: ":musical_note: Track",
playDescription2: "%radio.station.track%", playDescription2: "%radio.station.track%",
nowplayingTitle: "Now Playing", playTitle3: ":stopwatch: Duration",
nowplayingDescription: "**%radio.station.name%**" + "\n" + "%radio.station.owner%" + "\n" + "%client.funcs.msToTime(completed)%" + "\n\n" + "%radio.station.track%", playDescription3: "%client.funcs.msToTime(completed)%",
noVoiceChannel: "You need to be in a voice channel to play radio!", 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!", noQuery: "You need to use a number or search for a supported station!",
noPermsConnect: "I cannot connect to your voice channel.", noPermsConnect: "I cannot connect to your voice channel.",