Added !stats command
This commit is contained in:
parent
08b2d46a43
commit
ef694b116f
7 changed files with 201 additions and 78 deletions
52
libs/Queries.js
Normal file
52
libs/Queries.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
const formatString = require('../helpers/strings').formatString
|
||||
|
||||
class Queries {
|
||||
constructor () {
|
||||
this.filter = null
|
||||
this.value = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction permettant de générer la query sur artist et title
|
||||
* @param {Array} line
|
||||
* @param {Integer} start
|
||||
*/
|
||||
setBaseFilter (line, start) {
|
||||
let value = ''
|
||||
for (let i = start; i < line.length; i += 1) {
|
||||
value += ' ' + line[i]
|
||||
}
|
||||
value = value.replace(' ', '')
|
||||
const filter = {
|
||||
$or: [
|
||||
{
|
||||
artist: formatString(value)
|
||||
},
|
||||
{
|
||||
title: formatString(value)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
this.filter = filter
|
||||
this.value = value
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter pour le filter
|
||||
* @return {Object}
|
||||
*/
|
||||
getFilter () {
|
||||
return this.filter
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter pour le texte filtré
|
||||
* @return {String}
|
||||
*/
|
||||
getValue () {
|
||||
return this.value
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Queries
|
Loading…
Add table
Add a link
Reference in a new issue