From c860dfd0b4c6146b3a5f895ead6fe739405a9d7e Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Fri, 26 Feb 2021 17:49:53 -0600 Subject: [PATCH] Fix announcements failing --- bot/awesomescibo.mjs | 14 ++++++++++---- bot/package.json | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bot/awesomescibo.mjs b/bot/awesomescibo.mjs index 92f343e..99221c0 100755 --- a/bot/awesomescibo.mjs +++ b/bot/awesomescibo.mjs @@ -21,7 +21,7 @@ if (fs.existsSync('numhits.txt')) { client.once('ready', () => { - console.log('Ready!'); + console.log(client.user.username); client.user.setActivity("for \"do be helping\"", { type: "WATCHING" }); }); @@ -30,10 +30,16 @@ client.on('guildCreate', guild => { }); client.on('message', async message => { - if (message.content.startsWith("do be announcing") && message.author.id === "745063586422063214") { + + if (message.content.startsWith("do be announcing") && message.author.id === "author-id") { var announcement = message.content.substring(17); - client.guilds.cache.array().forEach((guild) => { - guild.channels.cache.find(channel => channel.name === 'general').send(announcement).catch((error) => { console.log(error) }) + client.guilds.cache.forEach((guild) => { + var channel = guild.channels.cache.find(channel => channel.name === 'general'); + if (channel) { + if (channel.type = "text") { + channel.send(announcement); + } + } }); } if (message.content.toLowerCase() === "do be hits") { diff --git a/bot/package.json b/bot/package.json index 3dbbfed..66e4f0b 100644 --- a/bot/package.json +++ b/bot/package.json @@ -5,7 +5,7 @@ "node-fetch": "^2.6.1" }, "name": "awscibo", - "version": "0.2.0", + "version": "0.2.2", "main": "awesomescibo.mjs", "bin": { "awscibo": "./awesomescibo.mjs"