Removed extra image request for image commands, various other tweaks
This commit is contained in:
parent
4439fca6d3
commit
ef071a39d4
39 changed files with 67 additions and 156 deletions
|
@ -14,14 +14,14 @@ const typeCheck = async (image) => {
|
|||
// if it is, then return the url with the file type
|
||||
return {
|
||||
type: imageType.ext,
|
||||
url: image
|
||||
data: imageBuffer
|
||||
};
|
||||
} else {
|
||||
// if not, then return a message
|
||||
return "Not the correct file type";
|
||||
// if not, then return false
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
if (error) console.error;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,7 @@ module.exports = async (cmdMessage) => {
|
|||
// get type of file
|
||||
const type = await typeCheck(message.attachments[0].url);
|
||||
// move to the next message if the file isn't an image
|
||||
if (type === "Not the correct file type") continue;
|
||||
if (type === false) continue;
|
||||
// if the file is an image then return it
|
||||
return type;
|
||||
// if there's nothing in the attachments check the embeds next
|
||||
|
@ -44,12 +44,12 @@ module.exports = async (cmdMessage) => {
|
|||
// embeds can have 2 possible entries with images, we check the thumbnail first
|
||||
if (message.embeds[0].thumbnail) {
|
||||
const type = await typeCheck(message.embeds[0].thumbnail.url);
|
||||
if (type === "Not the correct file type") continue;
|
||||
if (type === false) continue;
|
||||
return type;
|
||||
// if there isn't a thumbnail check the image area
|
||||
} else if (message.embeds[0].image) {
|
||||
const type = await typeCheck(message.embeds[0].image.url);
|
||||
if (type === "Not the correct file type") continue;
|
||||
if (type === false) continue;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ const logger = winston.createLogger({
|
|||
format: winston.format.printf(log => `[${moment().format("YYYY-MM-DD HH:mm:ss")}]: [${log.level.toUpperCase()}] - ${log.message}`)
|
||||
});
|
||||
|
||||
exports.log = (type, content) => content ? logger.log(type, content) : logger.log("info", content);
|
||||
exports.log = (type, content) => content ? logger.log(type, content) : logger.log("info", type);
|
||||
|
||||
exports.error = (...args) => this.log("error", ...args);
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ exports.clean = async (text) => {
|
|||
.replace(config.catToken, "<redacted>")
|
||||
.replace(config.googleKey, "<redacted>")
|
||||
.replace(config.cseID, "<redacted>")
|
||||
.replace(config.dblToken, "<redacted>");
|
||||
.replace(config.dblToken, "<redacted>")
|
||||
.replace(config.mongoURL, "<redacted>");
|
||||
|
||||
return text;
|
||||
};
|
||||
|
|
|
@ -6,18 +6,24 @@ module.exports = async (sound, message) => {
|
|||
if (message.member.voiceState.channelID) {
|
||||
if (!message.channel.guild.members.get(client.user.id).permission.has("voiceConnect") || !message.channel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I can't join this voice channel!`);
|
||||
const voiceChannel = message.channel.guild.channels.get(message.member.voiceState.channelID);
|
||||
client.createMessage(message.channel.id, "🔊 Playing sound...");
|
||||
if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I don't have permission to join this voice channel!`);
|
||||
const playingMessage = await client.createMessage(message.channel.id, "🔊 Playing sound...");
|
||||
const connection = await client.joinVoiceChannel(voiceChannel.id);
|
||||
console.log(connection.current);
|
||||
if (connection.playing) {
|
||||
connection.stopPlaying();
|
||||
connection.play(fs.createReadStream(sound));
|
||||
} else {
|
||||
connection.play(fs.createReadStream(sound));
|
||||
}
|
||||
connection.play(fs.createReadStream(sound));
|
||||
connection.on("error", (error) => {
|
||||
voiceChannel.leave();
|
||||
playingMessage.delete();
|
||||
logger.error(error);
|
||||
});
|
||||
connection.once("end", () => {
|
||||
voiceChannel.leave();
|
||||
playingMessage.delete();
|
||||
});
|
||||
} else {
|
||||
client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue