After scouring the internet, I have yet to find a solution to my Discord bot issue. My bot is built with Typescript and all of its commands are neatly organized in their own folder, each in a separate file.
I've come across suggestions to use
client.channels.get(`channelID`).send(`Text`)
However, this leads to errors such as Object is possibly 'undefined'.
and
Property 'send' does not exist on type 'Channel'.
My goal is to make the bot send a message to every text channel from a specified list whenever someone triggers a reboot command. It started as a playful prank, but now it's causing some inconvenience with the constant requests for reboots. The bot goes offline for 3 minutes during the reboot, and I don't want it to be rendered unusable due to spamming.
In my attempt to achieve this, I'm using
client.channels.get(channels.channelnames[5]).send("This is a message.")