mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2025-07-01 07:43:38 +00:00
Updated src
This commit is contained in:
20
src/client/funcs/check.js
Normal file
20
src/client/funcs/check.js
Normal file
@ -0,0 +1,20 @@
|
||||
module.exports = function (client, msg, command) {
|
||||
let message = {};
|
||||
const radio = client.radio.get(msg.guild.id);
|
||||
const permissions = msg.channel.permissionsFor(msg.author);
|
||||
if (!radio) {
|
||||
msg.channel.send(client.messageEmojis["error"] + client.messages.notPlaying);
|
||||
return false;
|
||||
}
|
||||
if (msg.member.voice.channel !== radio.voiceChannel) {
|
||||
msg.channel.send(client.messageEmojis["error"] + client.messages.wrongVoiceChannel);
|
||||
return false;
|
||||
}
|
||||
if(!command.permission == 'none'){
|
||||
if (!permissions.has(command.permission)) {
|
||||
message.noPerms = client.messages.noPerms.replace("%command.permission%", command.permission);
|
||||
msg.channel.send(client.messageEmojis["error"] + message.noPerms);
|
||||
return false;
|
||||
} else return true;
|
||||
} else return true;
|
||||
};
|
7
src/client/funcs/checkFetchStatus.js
Normal file
7
src/client/funcs/checkFetchStatus.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = function (response) {
|
||||
if (response.ok) { // res.status >= 200 && res.status < 300
|
||||
return response;
|
||||
} else {
|
||||
throw new Error(response.status + " " + response.statusText);
|
||||
}
|
||||
}
|
10
src/client/funcs/isDev.js
Normal file
10
src/client/funcs/isDev.js
Normal file
@ -0,0 +1,10 @@
|
||||
module.exports = function (devList, authorID){
|
||||
let response = false;
|
||||
Object.keys(devList).forEach(function(oneDev) {
|
||||
devID = devList[oneDev];
|
||||
if(authorID == devID){
|
||||
response = true;
|
||||
}
|
||||
});
|
||||
return response;
|
||||
}
|
17
src/client/funcs/msToTime.js
Normal file
17
src/client/funcs/msToTime.js
Normal file
@ -0,0 +1,17 @@
|
||||
module.exports = function msToTime(duration, format) {
|
||||
var seconds = Math.floor((duration / 1000) % 60),
|
||||
minutes = Math.floor((duration / (1000 * 60)) % 60),
|
||||
hours = Math.floor((duration / (1000 * 60 * 60)) % 24),
|
||||
days = Math.floor((duration / (1000 * 60 * 60 * 24)));
|
||||
|
||||
days = (days < 10) ? "0" + days : days;
|
||||
hours = (hours < 10) ? "0" + hours : hours;
|
||||
minutes = (minutes < 10) ? "0" + minutes : minutes;
|
||||
seconds = (seconds < 10) ? "0" + seconds : seconds;
|
||||
|
||||
if (format === "hh:mm:ss") {
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
} else if (format === "dd:hh:mm:ss") {
|
||||
return `${days}:${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
}
|
26
src/client/funcs/statisticsUpdate.js
Normal file
26
src/client/funcs/statisticsUpdate.js
Normal file
@ -0,0 +1,26 @@
|
||||
module.exports = function statisticsUpdate(client, guild, radio) {
|
||||
|
||||
client.datastore.checkEntry(guild.id);
|
||||
|
||||
radio.currentGuild = client.datastore.getEntry(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(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(guild, radio.currentGuild);
|
||||
client.datastore.calculateGlobal(client);
|
||||
}
|
Reference in New Issue
Block a user