Typescript Continuum

This commit is contained in:
Christer Warén 2023-06-05 00:13:15 +03:00
parent 0e62861e33
commit c584e3632e
33 changed files with 152 additions and 94 deletions

View File

@ -4,7 +4,7 @@ import Radio from "./client/classes/Radio";
import Stations from "./client/classes/Stations";
import Streamer from "./client/classes/Streamer";
import Statistics from "./client/classes/Statistics";
import { command } from "./client/utils/typings";
import { command } from "./client/commands";
import config from "./config";
import messages from "./client/messages";
import events from "./client/events"
@ -28,6 +28,8 @@ export default class RadioClient extends Client {
public streamer: Streamer | null;
public statistics: Statistics | null;
public radio: Radio | null;
public messageEmojis: any | null;
public developers: string | undefined;
constructor() {
super({
@ -39,6 +41,7 @@ export default class RadioClient extends Client {
this.streamer = null;
this.statistics = null;
this.radio = null;
this.messageEmojis = null;
this.events = events;
this.funcs = funcs;

View File

@ -1,4 +1,6 @@
import { getVoiceConnection, joinVoiceChannel } from "@discordjs/voice";
import { VoiceChannel } from "discord.js";
import RadioClient from "../../Client";
export default class Radio extends Map {
@ -6,7 +8,7 @@ export default class Radio extends Map {
super();
}
save(client: any) {
save(client: RadioClient) {
let currentRadios = this.keys();
let radio = currentRadios.next();
@ -14,9 +16,9 @@ export default class Radio extends Map {
let currentRadio = this.get(radio.value);
if (currentRadio) {
currentRadio.guild = client.datastore.getEntry(radio.value).guild;
currentRadio.guild = client.datastore?.getEntry(radio.value).guild;
client.statistics.update(client, currentRadio.guild, currentRadio);
client.statistics?.update(client, currentRadio.guild, currentRadio);
client.funcs.saveState(client, currentRadio.guild, currentRadio);
currentRadio.connection?.destroy();
currentRadio.message?.delete();
@ -27,7 +29,7 @@ export default class Radio extends Map {
}
}
restore(client: any, guilds: any) {
restore(client: RadioClient, guilds: any) {
if(!client.stations) return;
guilds.forEach(async (guild: { id: any; }) => {
@ -39,7 +41,7 @@ export default class Radio extends Map {
if(voiceChannel.members.filter((member: { user: { bot: any; }; }) => !member.user.bot).size === 0) return;
const sstation = await client.stations.search(state.station.name, "direct");
const sstation = await client.stations?.search(state.station.name, "direct");
let station = sstation;
if(!station) return;
@ -65,7 +67,7 @@ export default class Radio extends Map {
construct.connection = connection;
let date = new Date();
construct.startTime = date.getTime();
client.datastore.checkEntry(guild.id);
client.datastore?.checkEntry(guild.id);
client.funcs.play(client, null, guild, station);
} catch (error) {
console.log(error);

View File

@ -1,4 +1,5 @@
import { Guild } from "discord.js";
import RadioClient from "../../Client";
export default class Statistics {
map: any;
@ -7,17 +8,17 @@ export default class Statistics {
this.map = new Map();
}
update(client: any, guild: Guild, radio: any) {
update(client: RadioClient, guild: Guild, radio: any) {
client.datastore.checkEntry(guild.id);
client.datastore?.checkEntry(guild.id);
radio.datastore = client.datastore.getEntry(guild.id);
radio.datastore = client.datastore?.getEntry(guild.id);
if(!radio.datastore.statistics[radio.station.name]){
radio.datastore.statistics[radio.station.name] = {};
radio.datastore.statistics[radio.station.name].time = 0;
radio.datastore.statistics[radio.station.name].used = 0;
client.datastore.updateEntry(guild, radio.datastore);
client.datastore?.updateEntry(guild, radio.datastore);
}
let date = new Date();
@ -26,13 +27,13 @@ export default class Statistics {
radio.datastore.statistics[radio.station.name].time = parseInt(radio.datastore.statistics[radio.station.name].time)+parseInt(radio.playTime);
radio.datastore.statistics[radio.station.name].used = parseInt(radio.datastore.statistics[radio.station.name].used)+1;
client.datastore.updateEntry(guild, radio.datastore);
client.datastore?.updateEntry(guild, radio.datastore);
this.calculateGlobal(client);
}
calculateGlobal(client: any){
calculateGlobal(client: RadioClient){
if(!client.stations) return;
if(!client.datastore.map) return;
if(!client.datastore?.map) return;
let guilds = client.datastore.map.keys();
let stations = client.stations;

View File

@ -1,5 +1,6 @@
import logger from "../funcs/logger";
import { createAudioPlayer, createAudioResource, NoSubscriberBehavior } from "@discordjs/voice";
import RadioClient from "../../Client";
export default class Streamer {
map: any;
@ -12,7 +13,7 @@ export default class Streamer {
this.logger = logger;
}
init(client: any){
init(client: RadioClient){
if(!client.config.streamerMode) return;
switch(client.config.streamerMode){
@ -35,12 +36,12 @@ export default class Streamer {
}
}
refresh(client: any){
refresh(client: RadioClient){
this.init(client);
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: { name: any; }) => station.name == streamer) == -1){
this.stop(streamer);
}
});
@ -111,7 +112,7 @@ export default class Streamer {
return audioPlayer;
}
leave(client: any) {
leave(client: RadioClient) {
if(!client.stations) return;
client.stations.forEach((station: any) => {
this.stop(station);

View File

@ -1,4 +1,5 @@
import { Snowflake } from "discord.js";
import RadioClient from "../Client";
import bug from "./commands/bug";
import help from "./commands/help";
import invite from "./commands/invite";
@ -12,20 +13,30 @@ import statistics from "./commands/statistics";
import status from "./commands/status";
import stop from "./commands/stop";
export interface command {
name: string,
description: string,
category: string,
options?: [],
execute: any
}
export default {
async execute(client: any) {
const commands : any = [ bug, help, invite, list, maintenance, next, nowplaying, play, prev, statistics, status, stop ];
async execute(client: RadioClient) {
const commands : command[] = [ bug, help, invite, list, maintenance, next, nowplaying, play, prev, statistics, status, stop ];
for(const command of commands){
client.commands.set(command.name, command);
}
if(!client.application) return;
client.funcs.logger('Application Commands', 'Started refreshing application (/) commands.');
if(client.config.devMode){
client.application.commands.set([]);
for(const command of commands){
let guilds = await client.guilds.fetch();
guilds.forEach(async (guild: { id: Snowflake; name: string; }) => {
if(!client.application) return;
client.application.commands.create({
name: command.name,
description: command.description,
@ -47,6 +58,7 @@ export default {
let guilds = await client.guilds.fetch();
guilds.forEach(async (guild: { id: Snowflake; }) => {
if(!client.application) return;
client.application.commands.set([], guild.id);
});
}

View File

@ -1,10 +1,11 @@
import { EmbedBuilder } from "discord.js";
import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'bug',
description: 'Report a bug',
category: 'info',
async execute(interaction: any, client: any) {
async execute(interaction: ChatInputCommandInteraction, client: RadioClient) {
let message : any = {};
message.bugTitle = client.messages.bugTitle.replace("%client.user.username%", client.user.username);
@ -13,7 +14,7 @@ export default {
const embed = new EmbedBuilder()
.setTitle(message.bugTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(message.bugDescription)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({

View File

@ -1,10 +1,11 @@
import { EmbedBuilder } from "discord.js";
import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'help',
description: 'Get help using bot',
category: 'info',
execute(interaction: any, client: any) {
execute(interaction: ChatInputCommandInteraction, client: RadioClient) {
let message: any = {};
const categories : any= [];
@ -22,7 +23,7 @@ export default {
const embed = new EmbedBuilder()
.setTitle(message.helpTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(message.helpDescription)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({

View File

@ -1,15 +1,16 @@
import { EmbedBuilder } from "discord.js";
import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'invite',
description: 'Invite Bot',
category: 'info',
execute(interaction: any, client: any) {
execute(interaction: ChatInputCommandInteraction, client: RadioClient) {
let message: any = {};
message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username);
const embed = new EmbedBuilder()
.setTitle(message.inviteTitle)
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.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({

View File

@ -1,10 +1,11 @@
import { EmbedBuilder } from "discord.js";
import { ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'list',
description: 'List radio stations',
category: 'radio',
execute(interaction: any, client: any) {
execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient) {
let message: any = {};
if(!client.stations) {
@ -15,7 +16,7 @@ export default {
});
}
const radio = client.radio.get(interaction.guild.id);
const radio = client.radio?.get(interaction.guild.id);
if(radio && !client.config.maintenanceMode){
client.funcs.listStations(client, interaction);
@ -29,7 +30,7 @@ export default {
let embed = new EmbedBuilder()
.setTitle(client.messages.listTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["list"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(stations)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({

View File

@ -1,4 +1,5 @@
import { ActionRowBuilder, EmbedBuilder, StringSelectMenuBuilder } from "discord.js";
import { ActionRowBuilder, ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuBuilder, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client";
import Streamer from "../classes/Streamer";
import commands from "../commands";
const _importDynamic = new Function('modulePath', 'return import(modulePath)');
@ -9,7 +10,7 @@ export default {
name: 'maintenance',
description: 'Bot Maintenance',
category: 'info',
async execute(interaction: any, client: any) {
async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient) {
let message: any = {};
if(!client.funcs.isDev(client.config.devId, interaction.user.id)) return interaction.reply({
@ -55,12 +56,12 @@ export default {
},
{
emoji: "💤",
label: "Streamer Mode Manual",
label: "Streamer Mode - Manual",
value: "10"
},
{
emoji: "📡",
label: "Streamer Mode Auto",
label: "Streamer Mode - Auto",
value: "11"
}
);
@ -85,7 +86,7 @@ export default {
const embed = new EmbedBuilder()
.setTitle(client.messages.maintenanceTitle)
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(options.find((option: { value: any; }) => option.value == action).label)
.setFooter({
text: client.messages.footerText,

View File

@ -1,8 +1,11 @@
import { ButtonInteraction, ChatInputCommandInteraction, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'next',
description: 'Next Station',
category: 'radio',
async execute(interaction: any, client: any, command: any) {
async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: any) {
if (client.funcs.check(client, interaction, command)) {
const radio = client.radio.get(interaction.guild.id);

View File

@ -1,13 +1,14 @@
import { EmbedBuilder } from "discord.js";
import { ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'nowplaying',
description: 'Current Radio Station',
category: 'radio',
async execute(interaction: any, client: any, command: any) {
async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: any) {
if (client.funcs.check(client, interaction, command)) {
let message: any = {};
const radio = client.radio.get(interaction.guild.id);
const radio = client.radio?.get(interaction.guild.id);
let date = new Date();
radio.currentTime = date.getTime();
@ -21,7 +22,7 @@ export default {
const embed = new EmbedBuilder()
.setTitle(client.messages.nowplayingTitle)
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messageEmojis["play"].replace(/[^0-9]+/g, '')))
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(message.nowplayingDescription)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({

View File

@ -1,5 +1,6 @@
import { ApplicationCommandOptionType, PermissionFlagsBits } from "discord.js";
import { ApplicationCommandOptionType, ButtonInteraction, ChatInputCommandInteraction, PermissionFlagsBits, StringSelectMenuInteraction } from "discord.js";
import { getVoiceConnection, joinVoiceChannel } from "@discordjs/voice";
import RadioClient from "../../Client";
export default {
name: "play",
@ -9,7 +10,7 @@ export default {
{ type: ApplicationCommandOptionType.String, name: "query", description: "Select station", required: false}
],
category: "radio",
async execute(interaction: any, client: any) {
async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient) {
let message: any = {};
if(client.config.maintenanceMode){

View File

@ -1,8 +1,12 @@
import { ButtonInteraction, ChatInputCommandInteraction, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client";
import { command } from "../commands";
export default {
name: 'prev',
description: 'Previous Station',
category: 'radio',
async execute(interaction: any, client: any, command: any) {
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);

View File

@ -1,15 +1,16 @@
import { EmbedBuilder } from "discord.js";
import { ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'statistics',
description: 'Show statistics',
category: 'info',
execute(interaction: any, client: any) {
execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient) {
let message: any = {};
let stations = client.stations;
let currentGuild = client.datastore.getEntry(interaction.guild.id);
let global = client.datastore.getEntry("global");
let currentGuild = client.datastore?.getEntry(interaction.guild.id);
let global = client.datastore?.getEntry("global");
let statistics = "";
if(!client.stations) {
@ -29,7 +30,7 @@ export default {
const embed = new EmbedBuilder()
.setTitle(client.messages.statisticsTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["statistics"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(statistics)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({

View File

@ -1,10 +1,11 @@
import { EmbedBuilder } from "discord.js";
import { ColorResolvable, EmbedBuilder } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'status',
description: 'Bot Status',
category: 'info',
async execute(interaction: any, client: any) {
async execute(interaction: any, client: RadioClient) {
let message: any = {};
message.statusTitle = client.messages.statusTitle.replace("%client.user.username%", client.user.username);
@ -13,7 +14,7 @@ export default {
const embed = new EmbedBuilder()
.setTitle(message.statusTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.addFields(
{ name: client.messages.statusField1, value: uptime },
{ name: client.messages.statusField2, value: client.config.version },

View File

@ -1,20 +1,21 @@
import { EmbedBuilder } from "discord.js";
import { ButtonInteraction, ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'stop',
description: 'Stop radio',
category: 'radio',
async execute(interaction: any, client: any, command: any) {
async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: any) {
if (client.funcs.check(client, interaction, command)) {
const radio = client.radio.get(interaction.guild.id);
client.statistics.update(client, interaction.guild, radio);
const radio = client.radio?.get(interaction.guild.id);
client.statistics?.update(client, interaction.guild, radio);
radio.connection?.destroy();
client.funcs.logger('Radio', interaction.guild.id + " / " + 'Stop');
const embed = new EmbedBuilder()
.setTitle(client.user.username)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["stop"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.addFields({
name: client.messages.nowplayingTitle,
value: "-"
@ -39,7 +40,7 @@ export default {
await radio.message?.delete();
}, 5000);
client.radio.delete(interaction.guild.id);
client.radio?.delete(interaction.guild.id);
interaction.reply({
content: client.messageEmojis["stop"] + client.messages.stop,

View File

@ -1,6 +1,8 @@
import RadioClient from "../Client";
export default {
name: 'emojis',
async execute(client: any): Promise<any> {
async execute(client: RadioClient): Promise<any> {
let customEmojis: any = {
logo: "<:RadioX:688765708808487072>",
eximiabots: "<:EximiaBots:693277919929303132>",

View File

@ -1,13 +1,15 @@
import RadioClient from "../../Client";
export default {
name: 'SIGINT',
execute(client: any) {
execute(client: RadioClient) {
client.user.setStatus('dnd');
client.streamer.leave(client);
client.radio.save(client);
client.streamer?.leave(client);
client.radio?.save(client);
setInterval(() => {
if(client.radio.size == 0){
if(client.radio?.size == 0){
process.exit();
}
}, 500);

View File

@ -1,6 +1,8 @@
import RadioClient from "../../Client";
export default {
name: 'SIGTERM',
execute(client: any) {
execute(client: RadioClient) {
process.emit('SIGINT');
}
}

View File

@ -1,8 +1,9 @@
import { PermissionFlagsBits } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'interactionCreate',
async execute(client: any, interaction: any) {
async execute(client: RadioClient, interaction: any) {
const permissions = interaction.channel.permissionsFor(interaction.client.user);
if (!permissions.has(PermissionFlagsBits.ViewChannel)) return;

View File

@ -1,10 +1,11 @@
import { Message } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'messageDelete',
async execute(client: any, msg: Message) {
async execute(client: RadioClient, msg: Message) {
if(!msg.author.bot || !msg.guild) return;
const radio = client.radio.get(msg.guild.id);
const radio = client.radio?.get(msg.guild.id);
if(!radio) return;
if(!radio.message) return;
if(msg.id != radio.message.id) return;

View File

@ -1,3 +1,4 @@
import RadioClient from "../../Client";
import Datastore from "../classes/Datastore";
import Radio from "../classes/Radio";
import Stations from "../classes/Stations";
@ -8,7 +9,7 @@ import commands from "../commands";
export default {
name: 'ready',
async execute(client: any) {
async execute(client: RadioClient) {
client.funcs.logger("Bot", "Ready");

View File

@ -1,6 +1,8 @@
import RadioClient from "../../Client";
export default {
name: 'uncaughtException',
execute(client: any, error: any) {
execute(client: RadioClient, error: any) {
client.funcs.logger("Error");
console.log(error.stack);
console.log('');

View File

@ -1,4 +1,5 @@
import { PermissionFlagsBits, VoiceState } from "discord.js";
import RadioClient from "../../Client";
const {
getVoiceConnection,
joinVoiceChannel
@ -6,7 +7,7 @@ const {
export default {
name: "voiceStateUpdate",
async execute(client: any, oldState: VoiceState, newState: VoiceState) {
async execute(client: RadioClient, oldState: VoiceState, newState: VoiceState) {
if (oldState.channel === null) return;
let change = false;
const radio = client.radio?.get(newState.guild.id);
@ -15,11 +16,11 @@ export default {
if (newState.member?.id === client.user.id && oldState.member?.id === client.user.id) {
if (newState.channel === null) {
client.statistics.update(client, newState.guild, radio);
client.statistics?.update(client, newState.guild, radio);
radio.connection?.destroy();
radio.message?.delete();
client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop');
return client.radio.delete(newState.guild.id);
return client.radio?.delete(newState.guild.id);
}
const newPermissions = newState.channel.permissionsFor(newState.client.user);
@ -37,11 +38,11 @@ export default {
1000
);
} catch (error) {
client.statistics.update(client, newState.guild, radio);
client.statistics?.update(client, newState.guild, radio);
radio.connection?.destroy();
radio.message?.delete();
client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop');
client.radio.delete(oldState.guild.id);
client.radio?.delete(oldState.guild.id);
}
return;
}
@ -56,11 +57,11 @@ export default {
setTimeout(() => {
if (!radio || !radio.connection || !radio.connection === null) return;
if (radio.voiceChannel.members.filter((member: { user: { bot: any; }; }) => !member.user.bot).size === 0) {
client.statistics.update(client, newState.guild, radio);
client.statistics?.update(client, newState.guild, radio);
radio.connection?.destroy();
radio.message?.delete();
client.funcs.logger('Radio', newState.guild.id + " / " + 'Stop');
client.radio.delete(newState.guild.id);
client.radio?.delete(newState.guild.id);
}
}, 5000);
}

View File

@ -1,6 +1,8 @@
import RadioClient from "../../Client";
export default {
name: 'warning',
execute(client: any, warning: any) {
execute(client: RadioClient, warning: Error) {
if(warning.name == "ExperimentalWarning" && warning.message.startsWith("stream/web")) return;
client.funcs.logger("Warning");

View File

@ -1,6 +1,8 @@
export default function check(client: any, interaction: any, command: any) {
import RadioClient from "../../Client";
export default function check(client: RadioClient, interaction: any, command: any) {
let message: any = {};
const radio = client.radio.get(interaction.guild.id);
const radio = client.radio?.get(interaction.guild.id);
if(client.config.maintenanceMode){
interaction.reply({
content: client.messageEmojis["error"] + client.messages.maintenance,

View File

@ -1,9 +1,12 @@
import { ActionRowBuilder, StringSelectMenuBuilder } from "discord.js";
import RadioClient from "../../Client";
export default function listStations(client: any, interaction: any){
export default function listStations(client: RadioClient, interaction: any){
let stations: any = new Array();
let options: any = new Array();
if(!client.stations) return;
stations = client.stations.forEach((station: { name?: any; owner?: any; label?: any; description?: any; value?: any; }) => {
if(station.name == "GrooveFM") return;
station = {

View File

@ -1,6 +1,8 @@
import { Guild } from "discord.js";
import RadioClient from "../../Client";
export default function loadState(client: any, guild: Guild){
export default function loadState(client: RadioClient, guild: Guild){
if(!client.datastore) return;
let data = client.datastore.getEntry(guild.id);
if(!data) return;
let state;

View File

@ -1,5 +1,5 @@
export default function logger(area : string, text: string){
let date = new Date();
console.log('[' + area + '] ' + date.toISOString());
console.log('[' + area + '] - ' + date.toISOString());
if(text) console.log(text + '\n');
}

View File

@ -1,9 +1,10 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ColorResolvable, EmbedBuilder } from "discord.js";
import RadioClient from "../../Client";
export default async function play(client: any, interaction: any, guild: any, station: any) {
export default async function play(client: RadioClient, interaction: any, guild: any, station: any) {
let message: any = {};
const radio = client.radio.get(guild.id);
const audioPlayer = client.streamer.listen(station);
const radio = client.radio?.get(guild.id);
const audioPlayer = client.streamer?.listen(station);
radio.connection.subscribe(audioPlayer);
client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name);
@ -16,7 +17,7 @@ export default async function play(client: any, interaction: any, guild: any, st
const embed = new EmbedBuilder()
.setTitle(client.user.username)
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messageEmojis["play"].replace(/[^0-9]+/g, '')))
.setColor(client.config.embedColor)
.setColor(client.config.embedColor as ColorResolvable)
.addFields({
name: client.messages.nowplayingTitle,
value: message.nowplayingDescription

View File

@ -1,4 +1,7 @@
export default function saveState(client: any, guild: any, radio: any){
import RadioClient from "../../Client";
export default function saveState(client: RadioClient, guild: any, radio: any){
if(!client.datastore) return;
client.datastore.checkEntry(guild.id);
let date = new Date();

View File

@ -1,3 +0,0 @@
export interface command { }
export interface radio {}