Hey everyone! I’m trying to make a bot that keeps an eye on another bot in my Discord server. I want it to do a few things:
Post an embed message in a channel when the target bot goes online or offline
Respond to a command like !botinfo with details about the target bot’s uptime, downtime, and when it was last online
I tried using a GitHub repo for this, but it didn’t work out. The bot just kept saying the target was online and crashed when I used the setup command.
I’m open to any programming language for this project. Just looking for a simple solution that works. Any ideas or code snippets would be super helpful! Thanks in advance for your help!
I’ve implemented a similar monitoring system using Node.js and the discord.js library. It’s quite straightforward to set up. You’ll want to utilize the ‘presenceUpdate’ event to detect when the target bot’s status changes. For tracking uptime and downtime, consider using a database like SQLite to store timestamps. This allows for persistence across bot restarts.
For the ‘!botinfo’ command, you can create a simple function that queries your stored data and calculates the relevant statistics. Remember to handle edge cases, such as when the bot hasn’t gone offline since you started monitoring.
One tip: Make sure your monitoring bot has the necessary permissions to view the target bot’s status. Without proper setup, you might encounter issues similar to what you experienced with the GitHub repo solution.
I’ve actually tackled a similar project recently. One approach that worked well for me was using Python with the discord.py library. It’s pretty versatile for this kind of task.
For monitoring the bot’s status, you can leverage the on_presence_update event. This triggers whenever a member’s presence changes, including your target bot. You’ll want to filter for just that specific bot’s ID.
Storing the uptime/downtime data is crucial. I used a simple JSON file to keep track of timestamps, but a lightweight database like SQLite could work too if you need more robust storage.
For the !botinfo command, you’d just need to calculate the differences between your stored timestamps. Be sure to handle cases where the bot hasn’t gone offline since you started monitoring.
One gotcha to watch out for: make sure your monitoring bot has the ‘Presence Intent’ enabled in the Discord Developer Portal. Without this, you won’t receive presence updates, which could explain the issues you had before.
Let me know if you need any clarification on these points. Good luck with your project!
hey luke, i’ve done smthin similar b4. try using discord.py library, it’s pretty easy. you can use on_member_update event to track status changes. for uptime, store timestamps when bot goes on/offline. !botinfo command just needs to calculate from those. lmk if u need more help!