mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2025-07-03 03:44:31 +00:00
Typescript Continuum
This commit is contained in:
@ -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);
|
||||
|
@ -1,6 +1,8 @@
|
||||
import RadioClient from "../../Client";
|
||||
|
||||
export default {
|
||||
name: 'SIGTERM',
|
||||
execute(client: any) {
|
||||
execute(client: RadioClient) {
|
||||
process.emit('SIGINT');
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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('');
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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");
|
||||
|
Reference in New Issue
Block a user