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