bulkdel
This commit is contained in:
parent
5ffb07c14c
commit
ba246d672d
|
@ -3,23 +3,30 @@ var fs = require('fs-extra');
|
||||||
module.exports = (lib) => {
|
module.exports = (lib) => {
|
||||||
lib.trigger.add({
|
lib.trigger.add({
|
||||||
name: 'delete',
|
name: 'delete',
|
||||||
call: /^\!(del|rm) (\d+)$/i,
|
call: /^\!(del|rm)$/i,
|
||||||
level: 100,
|
level: 100,
|
||||||
active: 0,
|
active: 0,
|
||||||
func: (e) => {
|
func: (e) => {
|
||||||
var id = e.message.split(' ')[1];
|
var ids = e.message.split(' ');
|
||||||
|
var ok = [];
|
||||||
|
var fail = [];
|
||||||
|
ids.shift();
|
||||||
|
for(var id in ids) {
|
||||||
|
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` = ?", id, (err, rows, fields) => {
|
||||||
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` = ?", id).on('end', () => {
|
||||||
fs.unlink(rows[0].dest);
|
fs.unlink(rows[0].dest);
|
||||||
fs.unlink("./t/"+id+".png");
|
fs.unlink("./t/"+id+".png");
|
||||||
e.reply("f0ck "+id+" deleted");
|
ok.push(id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
e.reply("404 - f0ck not found");
|
fail.push(id);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.reply(ok+" from "+(ok+fail)+" f0cks deleted");
|
||||||
},
|
},
|
||||||
desc: 'delete f0ck'
|
desc: 'delete f0ck'
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user