Skip to content

Commit dc3b9d4

Browse files
barnabwhyactions-user
authored andcommitted
image v1.2.1
1 parent 2b6b223 commit dc3b9d4

File tree

4 files changed

+217
-136
lines changed

4 files changed

+217
-136
lines changed

modules/commands.js

+49-34
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ let { findImage, sendImage } = require("./utils");
1717
const { parseMsg, isCmd } = require("./parse");
1818

1919
let runMusicCmd;
20-
if(process.env.MUSIC_ENABLED == "true") {
21-
runMusicCmd = require("@frogebot/music")({
22-
BOT_NAME: process.env.BOT_NAME,
23-
EMBED_COLOUR: process.env.EMBED_COLOUR,
24-
MSG_VIBING: process.env.MSG_VIBING,
25-
MSG_UNVIBING: process.env.MSG_UNVIBING,
26-
SKIP_PERCENT: process.env.SKIP_PERCENT,
27-
USE_MUSIC_ROLE: process.env.USE_MUSIC_ROLE,
28-
MUSIC_ROLE_NAME: process.env.MUSIC_ROLE_NAME,
29-
TOKEN: process.env.TOKEN
30-
})
20+
if (process.env.MUSIC_ENABLED == "true") {
21+
runMusicCmd = require("@frogebot/music")({
22+
BOT_NAME: process.env.BOT_NAME,
23+
EMBED_COLOUR: process.env.EMBED_COLOUR,
24+
MSG_VIBING: process.env.MSG_VIBING,
25+
MSG_UNVIBING: process.env.MSG_UNVIBING,
26+
SKIP_PERCENT: process.env.SKIP_PERCENT,
27+
USE_MUSIC_ROLE: process.env.USE_MUSIC_ROLE,
28+
MUSIC_ROLE_NAME: process.env.MUSIC_ROLE_NAME,
29+
TOKEN: process.env.TOKEN,
30+
});
3131
}
3232

3333
async function handleCmdMsg(msg) {
@@ -41,12 +41,20 @@ async function handleCmdMsg(msg) {
4141
handleCmd(msg, cmd, args);
4242
}
4343
async function handleCmdInteraction(interaction) {
44-
if(interaction.isCommand()) {
44+
if (interaction.isCommand()) {
4545
let cmd = commands[interaction.commandName];
46-
let args = cmd.options ? cmd.options.map(o => { if(interaction.options.get(o.name)) { return interaction.options.get(o.name).value } else { return undefined } }) : []
46+
let args = cmd.options
47+
? cmd.options.map((o) => {
48+
if (interaction.options.get(o.name)) {
49+
return interaction.options.get(o.name).value;
50+
} else {
51+
return undefined;
52+
}
53+
})
54+
: [];
4755
handleCmd(interaction, cmd, args);
4856
}
49-
if(interaction.isContextMenu()) {
57+
if (interaction.isContextMenu()) {
5058
let cmd = commands[interaction.commandName];
5159
let args = [interaction.targetId];
5260
handleCmd(interaction, cmd, args);
@@ -57,7 +65,8 @@ async function handleCmd(interaction, cmd, args) {
5765
let startTime = new Date().getTime();
5866
cmdUses += 1;
5967

60-
if (cmd.type == "script") { // If command is set as script type
68+
if (cmd.type == "script") {
69+
// If command is set as script type
6170
// Debug clear cache
6271
// delete require.cache[require.resolve("../" + cmd.path)];
6372

@@ -69,7 +78,10 @@ async function handleCmd(interaction, cmd, args) {
6978
// If command is set as image type
7079
let imageUrl = await findImage(interaction); // Find image in channel
7180
try {
72-
let procMsg = await interaction.reply({ content: process.env.MSG_PROCESSING, fetchReply: true });
81+
let procMsg = await interaction.reply({
82+
content: process.env.MSG_PROCESSING,
83+
fetchReply: true,
84+
});
7385
// msg.channel.startTyping();
7486

7587
let r;
@@ -125,8 +137,10 @@ async function handleCmd(interaction, cmd, args) {
125137
// Execute command
126138
let img;
127139
if (cmd.library == "jimp") img = await exec(imageUrl, list, interaction);
128-
if (cmd.library == "magick") img = await execGM(imageUrl, list, interaction);
129-
if (cmd.library == "native") img = await execGPU(imageUrl, list, interaction);
140+
if (cmd.library == "magick")
141+
img = await execGM(imageUrl, list, interaction);
142+
if (cmd.library == "native")
143+
img = await execGPU(imageUrl, list, interaction);
130144

131145
let extension = await getFormat(imageUrl);
132146

@@ -139,30 +153,31 @@ async function handleCmd(interaction, cmd, args) {
139153
// procMsg.delete();
140154
interaction.editReply({
141155
content: `${process.env.MSG_UNVIBING} An error occurred`,
142-
embeds: [{
143-
title: "Error",
144-
description: `<@${interaction.member.id}> - ${
145-
imageUrl != undefined
146-
? process.env.MSG_ERROR
147-
: process.env.MSG_NO_IMAGE
148-
}\n${ "```"+e+"```" }`,
149-
color: Number(process.env.EMBED_COLOUR),
150-
timestamp: new Date(),
151-
author: {
152-
name: process.env.BOT_NAME,
153-
icon_url: interaction.client.user.displayAvatarURL(),
156+
embeds: [
157+
{
158+
title: "Error",
159+
description: `<@${interaction.member.id}> - ${
160+
imageUrl != undefined
161+
? process.env.MSG_ERROR
162+
: process.env.MSG_NO_IMAGE
163+
}\n${"```" + e + "```"}`,
164+
color: Number(process.env.EMBED_COLOUR),
165+
timestamp: new Date(),
166+
author: {
167+
name: process.env.BOT_NAME,
168+
icon_url: interaction.client.user.displayAvatarURL(),
169+
},
154170
},
155-
}],
171+
],
156172
});
157173
}
158174
} else if (cmd.type == "music" && process.env.MUSIC_ENABLED == "true") {
159175
// If command is set as music type
160-
runMusicCmd(msg, args, cmd)
176+
runMusicCmd(msg, args, cmd);
161177
}
162178
}
163179

164-
165180
module.exports = {
166181
handleCmdMsg,
167-
handleCmdInteraction
182+
handleCmdInteraction,
168183
};

0 commit comments

Comments
 (0)