fixed
This commit is contained in:
parent
36fcb30630
commit
9ddb8ad7d4
|
@ -2,31 +2,30 @@ var fs = require('fs-extra');
|
||||||
|
|
||||||
module.exports = (lib) => {
|
module.exports = (lib) => {
|
||||||
lib.trigger.add({
|
lib.trigger.add({
|
||||||
name: 'delete',
|
name: 'del',
|
||||||
call: /^\!(del|rm)/i,
|
call: /^\!(del|rm)/i,
|
||||||
level: 100,
|
level: 100,
|
||||||
active: 0,
|
active: 0,
|
||||||
func: (e) => {
|
func: (e) => {
|
||||||
var ids = e.message.split(' ');
|
var ids = e.message.split(' ');
|
||||||
var ok = [];
|
|
||||||
var fail = [];
|
|
||||||
ids.shift();
|
ids.shift();
|
||||||
for(var id in ids) {
|
ids.forEach(id => {
|
||||||
if(Number.isInteger(parseInt(id))) {
|
if(Number.isInteger(parseInt(id))) {
|
||||||
lib.sql.query("select `dest` from `f0ck`.`items` where `id` = ?", id, (err, rows, fields) => {
|
lib.sql.query("select `dest` from `f0ck`.`items` where `id` = ? limit 1", id, (err, rows) => {
|
||||||
if(rows[0]) {
|
if(rows[0]) {
|
||||||
lib.sql.query("delete from `f0ck`.`items` where `id` = ?", id).on('end', () => {
|
lib.sql.query("delete from `f0ck`.`items` where `id` = ? limit 1", id, err => {
|
||||||
fs.unlink(rows[0].dest);
|
if(!err) {
|
||||||
fs.unlink("./t/"+id+".png");
|
fs.unlink(rows[0].dest, err => {});
|
||||||
ok.push(id);
|
fs.unlink("./t/"+id+".png", err => {});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
e.reply(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
|
||||||
fail.push(id);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
e.reply(ok.length+" from "+(ok.length+fail.length)+" f0cks deleted");
|
e.reply("f0ck"+(ids.length>1?"s":"")+" deleted");
|
||||||
},
|
},
|
||||||
desc: 'delete f0ck'
|
desc: 'delete f0ck'
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user