Categorygithub.com/Alextopher/apod-bot
modulepackage
0.0.0-20240628203544-b1838e96a1a0
Repository: https://github.com/alextopher/apod-bot.git
Documentation: pkg.go.dev

# README

apod-bot

A discord bot written in go that fetches and posts NASA's Astronomy Picture of the Day.

:O

Features

  • Scheduled posting with /schedule and /stop
  • Manually posting today's picture with /today
  • Post a random picture with /random
  • Relive a previous APOD picture with /specific <date>
  • Get more information with /explanation
  • Astronomy Picture of the Day API calls are cached
  • Today's picture is saved in memory for a faster roundtrip

Usage

  1. Invite the bot to your server. https://discord.com/api/oauth2/authorize?client_id=952282891910512663&permissions=18432&scope=applications.commands%20bot

  2. Go to the channel you want APOD messages posted.

  3. Call /schedule <hour UTC> with the hour you want APOD messages to be sent.

I do keep some metrics of the bot usage. Including but not limited to server names, channel ids, and command usage. Feel free to self-host it instead!

Development

APOD_TOKEN and DISCORD_TOKEN are required as environment variables. These are set in a .env file like so:

APOD_TOKEN=<token>
DISCORD_TOKEN=<token>

# Optionally include an owner id to send certain events to.
OWNER_ID=<id>

To learn more about discord bot development, visit discord developers docs. To create a NASA API token visit api.nasa.gov.

# Packages

No description provided by the author

# Functions

NewDB creates a new DB.
NewResponse creates a new response handler for an interaction.

# Constants

EventTypeRemove is a remove event (/stop).
EventTypeSent is a sent event (APOD sent).
EventTypeSet is a set event (/schedule).

# Variables

ErrResponseSent for when a response has already been sent to an interaction.

# Structs

Bot is the discord bot.
DB is the bot's database.
Event is a database event.
RemoveEvent removes a channel from the schedule.
Response wraps a discord interaction to simplify sending messages This struct will automatically send a deferral is the response has taken more than 2 seconds to create.
SentEvent tracks the last APOD sent to a channel.
SetEvent adds a channel to the schedule.

# Type aliases

EventType enum.