mirror of
				https://github.com/warengroup/eximiabots-radiox.git
				synced 2025-11-04 03:09:32 +00:00 
			
		
		
		
	Typings
This commit is contained in:
		@@ -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 RadioClient from "../../Client";
 | 
			
		||||
import { station } from "./Stations";
 | 
			
		||||
import { datastore } from "./Datastore";
 | 
			
		||||
 | 
			
		||||
export interface radio {
 | 
			
		||||
    textChannel: Channel | TextBasedChannel | undefined | null,
 | 
			
		||||
    voiceChannel: Channel | VoiceBasedChannel | undefined,
 | 
			
		||||
    textChannel: TextBasedChannel | undefined | null,
 | 
			
		||||
    voiceChannel: VoiceBasedChannel | undefined,
 | 
			
		||||
    connection: VoiceConnection | null,
 | 
			
		||||
    message: null,
 | 
			
		||||
    message: Message | null,
 | 
			
		||||
    station: station,
 | 
			
		||||
    datastore?: datastore,
 | 
			
		||||
    currentTime?: number,
 | 
			
		||||
    startTime: number,
 | 
			
		||||
    playTime?: number,
 | 
			
		||||
    guild?: any
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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() {
 | 
			
		||||
        super();
 | 
			
		||||
@@ -75,8 +76,8 @@ export default class Radio extends Map {
 | 
			
		||||
 | 
			
		||||
            let date = new Date();
 | 
			
		||||
            const construct: radio = {
 | 
			
		||||
                textChannel: client.channels.cache.get(state.channels.text),
 | 
			
		||||
                voiceChannel: client.channels.cache.get(state.channels.voice),
 | 
			
		||||
                textChannel: client.channels.cache.get(state.channels.text) as TextBasedChannel,
 | 
			
		||||
                voiceChannel: client.channels.cache.get(state.channels.voice) as VoiceBasedChannel,
 | 
			
		||||
                connection: null,
 | 
			
		||||
                message: null,
 | 
			
		||||
                station: station,
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,9 @@ export default {
 | 
			
		||||
    category: 'radio',
 | 
			
		||||
    async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) {
 | 
			
		||||
        if (client.funcs.check(client, interaction, command)) {
 | 
			
		||||
            if(!interaction.guild) return;
 | 
			
		||||
            const radio = client.radio?.get(interaction.guild?.id);
 | 
			
		||||
            if(!radio) return;
 | 
			
		||||
 | 
			
		||||
            if(client.config.maintenanceMode){
 | 
			
		||||
                return interaction.reply({
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,9 @@ export default {
 | 
			
		||||
    category: 'radio',
 | 
			
		||||
    async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) {
 | 
			
		||||
        if (client.funcs.check(client, interaction, command)) {
 | 
			
		||||
            if(!interaction.guild) return;
 | 
			
		||||
            const radio = client.radio?.get(interaction.guild?.id);
 | 
			
		||||
            if(!radio) return;
 | 
			
		||||
 | 
			
		||||
            if(client.config.maintenanceMode){
 | 
			
		||||
                return interaction.reply({
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,9 @@ export default {
 | 
			
		||||
    category: 'radio',
 | 
			
		||||
    async execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient, command: command) {
 | 
			
		||||
        if (client.funcs.check(client, interaction, command)) {
 | 
			
		||||
            if(!interaction.guild) return;
 | 
			
		||||
            const radio = client.radio?.get(interaction.guild?.id);
 | 
			
		||||
            if(!radio) return;
 | 
			
		||||
            client.statistics?.update(client, interaction.guild, radio);
 | 
			
		||||
            radio.connection?.destroy();
 | 
			
		||||
            client.funcs.logger('Radio', interaction.guild?.id + " / " + 'Stop');
 | 
			
		||||
@@ -28,9 +30,9 @@ export default {
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            if(!radio.message){
 | 
			
		||||
                radio.message = radio.textChannel.send({ embeds: [embed], components: [] });
 | 
			
		||||
                radio.message = await radio.textChannel?.send({ embeds: [embed], components: [] }) ?? null;
 | 
			
		||||
            } else {
 | 
			
		||||
                if(radio.textChannel.id == radio.message.channel.id){
 | 
			
		||||
                if(radio.textChannel?.id == radio.message.channel.id){
 | 
			
		||||
                    radio.message.edit({ embeds: [embed], components: [] });
 | 
			
		||||
                } else {
 | 
			
		||||
                    radio.message?.delete();
 | 
			
		||||
@@ -41,7 +43,7 @@ export default {
 | 
			
		||||
                await radio.message?.delete();
 | 
			
		||||
            }, 5000);
 | 
			
		||||
 | 
			
		||||
            client.radio?.delete(interaction.guild?.id);
 | 
			
		||||
            client.radio?.delete(interaction.guild.id);
 | 
			
		||||
 | 
			
		||||
            interaction.reply({
 | 
			
		||||
                content: client.messages.emojis["stop"] + client.messages.stop,
 | 
			
		||||
 
 | 
			
		||||
@@ -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) {
 | 
			
		||||
        setTimeout(() => {
 | 
			
		||||
            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);
 | 
			
		||||
                radio.connection?.destroy();
 | 
			
		||||
                radio.message?.delete();
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ import { command } from "../commands";
 | 
			
		||||
 | 
			
		||||
export default function check(client: RadioClient, interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, command: command) {
 | 
			
		||||
 | 
			
		||||
    if(!interaction.guild) return;
 | 
			
		||||
    const radio = client.radio?.get(interaction.guild?.id);
 | 
			
		||||
    if(!client.stations) {
 | 
			
		||||
        interaction.reply({
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user