TypeScript types

This commit is contained in:
Christer Warén
2023-06-04 05:48:42 +03:00
parent 9303c4fcc9
commit 3fc7337d0f
36 changed files with 131 additions and 119 deletions

View File

@ -1,6 +1,6 @@
export default {
name: 'SIGINT',
execute(client) {
execute(client: any) {
client.user.setStatus('dnd');
client.streamer.leave(client);

View File

@ -1,6 +1,6 @@
export default {
name: 'SIGTERM',
execute(client) {
execute(client: any) {
process.emit('SIGINT');
}
}

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import Statistics from "../classes/Statistics";
export default {
name: 'ready',
async execute(client) {
async execute(client: any) {
client.funcs.logger("Bot", "Ready");
@ -14,7 +14,7 @@ export default {
client.funcs.logger('Datastore', 'Initialize');
client.datastore = new Datastore();
client.datastore.map.forEach(datastore => {
client.datastore.map.forEach((datastore: { guild: { id: string; name: string; }; }) => {
client.funcs.logger('Datastore', datastore.guild.id + " / " + datastore.guild.name);
});
@ -22,7 +22,7 @@ export default {
/*DEVELOPERS*/
client.developers = "";
let user = "";
let user : any= "";
for (let i = 0; i < client.config.devId.length; i++) {
user = await client.users.fetch(client.config.devId[i]);
client.funcs.logger('Developers', user.tag);
@ -59,7 +59,7 @@ export default {
client.funcs.logger('Guilds', 'Started fetching list');
let guilds = await client.guilds.fetch();
guilds.forEach(guild => {
guilds.forEach((guild: { id: string; name: string; }) => {
client.funcs.logger('Guilds', guild.id + " / " + guild.name);
});

View File

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

View File

@ -1,4 +1,4 @@
import { PermissionFlagsBits } from "discord.js";
import { PermissionFlagsBits, VoiceState } from "discord.js";
const {
getVoiceConnection,
joinVoiceChannel
@ -6,13 +6,13 @@ const {
export default {
name: "voiceStateUpdate",
async execute(client, oldState, newState) {
async execute(client: any, oldState: VoiceState, newState: VoiceState) {
if (oldState.channel === null) return;
let change = false;
const radio = client.radio?.get(newState.guild.id);
if (!radio) return;
if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
if (newState.member?.id === client.user.id && oldState.member?.id === client.user.id) {
if (newState.channel === null) {
client.statistics.update(client, newState.guild, radio);
@ -23,14 +23,14 @@ export default {
}
const newPermissions = newState.channel.permissionsFor(newState.client.user);
if (!newPermissions.has(PermissionFlagsBits.Connect) || !newPermissions.has(PermissionFlagsBits.Speak) || !newPermissions.has(PermissionFlagsBits.ViewChannel)) {
if (!newPermissions?.has(PermissionFlagsBits.Connect) || !newPermissions?.has(PermissionFlagsBits.Speak) || !newPermissions?.has(PermissionFlagsBits.ViewChannel)) {
try {
setTimeout(
async () => (
radio.connection = joinVoiceChannel({
channelId: oldState.channel.id,
guildId: oldState.channel.guild.id,
adapterCreator: oldState.channel.guild.voiceAdapterCreator
channelId: oldState.channel?.id,
guildId: oldState.channel?.guild.id,
adapterCreator: oldState.channel?.guild.voiceAdapterCreator
})
//radio.connection = await oldState.channel.join()
),
@ -55,7 +55,7 @@ export default {
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 => !member.user.bot).size === 0) {
if (radio.voiceChannel.members.filter((member: { user: { bot: any; }; }) => !member.user.bot).size === 0) {
client.statistics.update(client, newState.guild, radio);
radio.connection?.destroy();
radio.message?.delete();

View File

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