diff --git a/Main.js b/Main.js index d4faa2e..944b38f 100644 --- a/Main.js +++ b/Main.js @@ -61,7 +61,7 @@ client.on("message", async msg => { if (msg.mentions.has(client.user) && !msg.isCommand) { const u = msg.cleanContent.replace(new RegExp("@" + (msg.guild ? msg.guild.member(client.user).displayName : msg.author.username)), "").trim(); - if (u.length > 0) trySend(client, msg, await chatAnswer(u)); + if (u.length > 0) await trySend(client, msg, await chatAnswer(u)); } if (!msg.guild) { diff --git a/resources/functions.js b/resources/functions.js index d68ad5c..69f3dac 100644 --- a/resources/functions.js +++ b/resources/functions.js @@ -169,7 +169,7 @@ async function trySend(client, msgOrChannel, content, checkAd = true) { for (const f of content.fields) fLength.push(f.value.length); console.log("Embed", content.title, timestampAt(client), "\n", content.description, content.description?.length, "\n", content.fields, fLength) }*/ - if (!client || !msgOrChannel) return; + if (!client || !msgOrChannel || !content) return; if (typeof msgOrChannel === "string") msgOrChannel = client.channels.cache.get(msgOrChannel); if (!client.user.typingIn(msgOrChannel.channel || msgOrChannel)) (msgOrChannel.channel || msgOrChannel).startTyping(); if (client.owners.includes(msgOrChannel.author)) { @@ -409,6 +409,7 @@ function getUTCComparison(compare) { * @returns {MessageEmbed} */ function defaultEventLogEmbed(guild) { + if (!guild) return; return new MessageEmbed() .setAuthor(guild.name) .setFooter((guild.defaultEmbed?.footerQuote ? guild.defaultEmbed.footerQuote : ""), guild.iconURL({ format: "png", size: 128, dynamic: true })) diff --git a/resources/shaChat.js b/resources/shaChat.js index 81438ae..1a16339 100644 --- a/resources/shaChat.js +++ b/resources/shaChat.js @@ -24,7 +24,9 @@ const URL = [ async function chatAnswer(message) { // return axios.post("https://rebot.me/ask", { username: "simsimi", question: message }).then(r => r.data).catch(() => { }); console.log(message); - return axios.get(`https://api.simsimi.net/v1/?text=${message.replace(/( |\n|\t)+/, "+").slice(0, 1000)}&lang=en`).then(r => { + const u = message.replace(/( |\n|\t)+/g, "+").slice(0, 1000); + console.log(u); + return axios.get(`https://api.simsimi.net/v1/?text=${u}&lang=en`).then(r => { console.log(r.data); return r.data.success.replace(/Sim doesn't know what you are talking about. Please teach me/, "Sorry but i don't speak gibberish"); }).catch(() => { });