Compare commits
No commits in common. "6a0350f13ca9bdabbcf79d5b7d0c395e63851ea9" and "c3f7abce5d42818c365e1d9a6c5d07a2b9e14b5f" have entirely different histories.
6a0350f13c
...
c3f7abce5d
1 changed files with 5 additions and 7 deletions
|
@ -10,10 +10,9 @@ module.exports = {
|
||||||
description: 'Combine picture with tdoss album cover template',
|
description: 'Combine picture with tdoss album cover template',
|
||||||
async execute({ message, args }) {
|
async execute({ message, args }) {
|
||||||
|
|
||||||
let tdossDir = path.resolve(process.cwd, 'data', 'tdoss');
|
let dataDir = path.resolve(__dirname, '..', '..', 'data');
|
||||||
|
const directory = path.resolve(dataDir, Math.floor(new Date).toString())
|
||||||
const directory = path.resolve(tdossDir, Math.floor(new Date).toString())
|
fs.mkdirSync(directory)
|
||||||
fs.mkdirSync(directory, {recursive: true})
|
|
||||||
|
|
||||||
let url = "";
|
let url = "";
|
||||||
if(message.attachments.size > 0){
|
if(message.attachments.size > 0){
|
||||||
|
@ -59,7 +58,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const command = `magick ${tdossDir}/tdoss_template.png \\( ${directory}/input.png -resize 800x800^ -gravity center -extent 1000x1000 \\) -compose dst-over -composite ${directory}/tdoss_result.png`;
|
const command = `magick ${dataDir}/tdoss_template.png \\( ${directory}/input.png -resize 800x800^ -gravity center -extent 1000x1000 \\) -compose dst-over -composite ${directory}/tdoss_result.png`;
|
||||||
if (this.executeCommand(command).error === true) {
|
if (this.executeCommand(command).error === true) {
|
||||||
message.channel.send("Something went wrong during image manipulation.\nTry again and if it keeps happening, contact the owner of the bot.")
|
message.channel.send("Something went wrong during image manipulation.\nTry again and if it keeps happening, contact the owner of the bot.")
|
||||||
fs.rmSync(`${directory}`, {recursive: true})
|
fs.rmSync(`${directory}`, {recursive: true})
|
||||||
|
@ -97,8 +96,7 @@ module.exports = {
|
||||||
return {value: 3, errorMessage: error.cause.message};
|
return {value: 3, errorMessage: error.cause.message};
|
||||||
}
|
}
|
||||||
if(!res.ok) return {value: 1, errorMessage: res.status.toString()};
|
if(!res.ok) return {value: 1, errorMessage: res.status.toString()};
|
||||||
const contentType = res.headers.get('content-type');
|
if(!res.headers.get('content-type').startsWith("image")) return {value: 2, errorMessage: ""};
|
||||||
if(!contentType || !contentType.startsWith("image")) return {value: 2, errorMessage: contentType || "No content-type header"};
|
|
||||||
const stream = Readable.fromWeb(res.body)
|
const stream = Readable.fromWeb(res.body)
|
||||||
await writeFile(path, stream);
|
await writeFile(path, stream);
|
||||||
return {value: 0, errorMessage: ""};
|
return {value: 0, errorMessage: ""};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue