Revert gmbuffer.js, improved tags a bit more, some more pagination work
This commit is contained in:
parent
16927d8667
commit
c9f0ff3827
3 changed files with 47 additions and 38 deletions
|
@ -1,37 +1,39 @@
|
|||
// workaround for a gm bug where it doesn't output buffers properly
|
||||
// https://github.com/aheckmann/gm/issues/572#issuecomment-293768810
|
||||
module.exports = async (data, format) => {
|
||||
if (format) {
|
||||
data.stream(format, (err, stdout, stderr) => {
|
||||
if (err) throw err;
|
||||
const chunks = [];
|
||||
stdout.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
module.exports = (data, format) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (format) {
|
||||
data.stream(format, (err, stdout, stderr) => {
|
||||
if (err) return reject(err);
|
||||
const chunks = [];
|
||||
stdout.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
// these are 'once' because they can and do fire multiple times for multiple errors,
|
||||
// but this is a promise so you'll have to deal with them one at a time
|
||||
stdout.once("end", () => {
|
||||
resolve(Buffer.concat(chunks));
|
||||
});
|
||||
stderr.once("data", (data) => {
|
||||
reject(String(data));
|
||||
});
|
||||
});
|
||||
// these are 'once' because they can and do fire multiple times for multiple errors,
|
||||
// but this is a promise so you'll have to deal with them one at a time
|
||||
stdout.once("end", () => {
|
||||
return Buffer.concat(chunks);
|
||||
} else {
|
||||
data.stream((err, stdout, stderr) => {
|
||||
if (err) return reject(err);
|
||||
const chunks = [];
|
||||
stdout.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
// these are 'once' because they can and do fire multiple times for multiple errors,
|
||||
// but this is a promise so you'll have to deal with them one at a time
|
||||
stdout.once("end", () => {
|
||||
resolve(Buffer.concat(chunks));
|
||||
});
|
||||
stderr.once("data", (data) => {
|
||||
reject(String(data));
|
||||
});
|
||||
});
|
||||
stderr.once("data", (data) => {
|
||||
throw data;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
data.stream((err, stdout, stderr) => {
|
||||
if (err) throw err;
|
||||
const chunks = [];
|
||||
stdout.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
// these are 'once' because they can and do fire multiple times for multiple errors,
|
||||
// but this is a promise so you'll have to deal with them one at a time
|
||||
stdout.once("end", () => {
|
||||
return Buffer.concat(chunks);
|
||||
});
|
||||
stderr.once("data", (data) => {
|
||||
throw data;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -45,6 +45,7 @@ const paginationEmbed = async (message, pages, timeout = 120000) => {
|
|||
if (manageMessages) msg.removeReaction("▶", userID);
|
||||
break;
|
||||
case "🗑":
|
||||
reactionCollector.emit("end");
|
||||
currentPage.delete();
|
||||
return;
|
||||
default:
|
||||
|
@ -52,7 +53,7 @@ const paginationEmbed = async (message, pages, timeout = 120000) => {
|
|||
}
|
||||
}
|
||||
});
|
||||
reactionCollector.on("end", () => {
|
||||
reactionCollector.once("end", () => {
|
||||
try {
|
||||
currentPage.removeReactions();
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue