Folder re-structuring

This commit is contained in:
Christer Warén 2020-04-02 08:40:05 +03:00
parent 5667e2f0a9
commit f300d9c0df
21 changed files with 192 additions and 192 deletions

View File

@ -2,7 +2,7 @@ const { Client, Collection } = require('discord.js');
const Discord = require('discord.js');
const fs = require('fs');
const path = require('path');
const events = '../events/';
const events = './events/';
const Datastore = require('./datastore.js');
module.exports = class extends Client {
@ -16,15 +16,16 @@ module.exports = class extends Client {
this.radio = new Map();
this.funcs = {};
this.funcs.check = require('../funcs/check.js');
this.funcs.msToTime = require('../funcs/msToTime.js');
this.funcs.check = require('./funcs/check.js');
this.funcs.msToTime = require('./funcs/msToTime.js');
this.funcs.statisticsUpdate = require('./funcs/statisticsUpdate.js');
this.config = require('../config.js');
this.config = require('./config.js');
this.messages = require('./messages.js');
const commandFiles = fs.readdirSync(path.join(path.dirname(__dirname), 'commands')).filter(f => f.endsWith('.js'));
const commandFiles = fs.readdirSync(path.join('commands')).filter(f => f.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`../commands/${file}`);
const command = require(`./commands/${file}`);
command.uses = 0;
this.commands.set(command.name, command);
this.commandAliases.set(command.alias, command);

View File

@ -32,6 +32,6 @@ module.exports = {
.then(res => res.json());
}, 3600000);
require(`../struct/emojis.js`).execute(client);
require(`./emojis.js`).execute(client);
}
}

View File

@ -43,30 +43,3 @@ module.exports = {
}
}
};
function statisticsUpdate(client, currentState, radio) {
client.datastore.checkEntry(currentState.guild.id);
radio.currentGuild = client.datastore.getEntry(currentState.guild.id);
if(!radio.currentGuild.statistics[radio.station.name]){
radio.currentGuild.statistics[radio.station.name] = {};
radio.currentGuild.statistics[radio.station.name].time = 0;
radio.currentGuild.statistics[radio.station.name].used = 0;
client.datastore.updateEntry(currentState.guild, radio.currentGuild);
}
if(!radio.connection.dispatcher){
let date = new Date();
radio.currentTime = date.getTime();
radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime);
radio.currentGuild.statistics[radio.station.name].time = parseInt(radio.currentGuild.statistics[radio.station.name].time)+parseInt(radio.playTime);
} else {
radio.currentGuild.statistics[radio.station.name].time = parseInt(radio.currentGuild.statistics[radio.station.name].time)+parseInt(radio.connection.dispatcher.streamTime.toFixed(0));
}
radio.currentGuild.statistics[radio.station.name].used = parseInt(radio.currentGuild.statistics[radio.station.name].used)+1;
client.datastore.updateEntry(currentState.guild, radio.currentGuild);
}

View File

@ -0,0 +1,26 @@
module.exports = function statisticsUpdate(client, currentState, radio) {
client.datastore.checkEntry(currentState.guild.id);
radio.currentGuild = client.datastore.getEntry(currentState.guild.id);
if(!radio.currentGuild.statistics[radio.station.name]){
radio.currentGuild.statistics[radio.station.name] = {};
radio.currentGuild.statistics[radio.station.name].time = 0;
radio.currentGuild.statistics[radio.station.name].used = 0;
client.datastore.updateEntry(currentState.guild, radio.currentGuild);
}
if(!radio.connection.dispatcher){
let date = new Date();
radio.currentTime = date.getTime();
radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime);
radio.currentGuild.statistics[radio.station.name].time = parseInt(radio.currentGuild.statistics[radio.station.name].time)+parseInt(radio.playTime);
} else {
radio.currentGuild.statistics[radio.station.name].time = parseInt(radio.currentGuild.statistics[radio.station.name].time)+parseInt(radio.connection.dispatcher.streamTime.toFixed(0));
}
radio.currentGuild.statistics[radio.station.name].used = parseInt(radio.currentGuild.statistics[radio.station.name].used)+1;
client.datastore.updateEntry(currentState.guild, radio.currentGuild);
}

View File

@ -1,2 +1,2 @@
const radioClient = require("./struct/client.js");
const radioClient = require("./client/class.js");
const client = new radioClient();