A Simple Discord Bot to speed up data entry

Here was my idea: I have a bunch of daily habits that I beemind against but tracking each of them is pretty tedious. What if I could have a conversation with ChatGPT and have ChatGPT write my daily updates? Then what’s the easiest way to get those updates entered into Beeminder?

Steps:

  1. Talk to chatgpt about my day and ask it to generate a list of daily habit updates
  2. Copy Paste those updates from ChatGPT into a discord message
  3. This discord bot listens to those messages and updates my goals using the beemindr API

sample discord bot code:

# beeminder_discord_bot.py
import discord
import requests
from datetime import datetime

# Replace these with your actual values
DISCORD_TOKEN = 'your_discord_bot_token'
DISCORD_CHANNEL_ID = 123456789012345678  # Replace with your channel ID
USERNAME = 'your_beeminder_username'
AUTH_TOKEN = 'your_beeminder_auth_token'

intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print(f'✅ Logged in as {client.user}')

@client.event
async def on_message(message):
    if message.channel.id != DISCORD_CHANNEL_ID or message.author.bot:
        return

    lines = message.content.strip().split('\n')
    today_prefix = datetime.now().strftime('%Y%m')  # For expanding short day format like "27" to "20250327"

    for line in lines:
        try:
            date_str, goal, value, comment = line.split(',', 3)
            goal = goal.strip()
            value = float(value.strip())
            comment = comment.strip()

            daystamp = date_str.strip()
            if len(daystamp) <= 2:  # If user just typed "27", assume current year/month
                daystamp = f"{today_prefix}{int(daystamp):02d}"

            url = f"https://www.beeminder.com/api/v1/users/{USERNAME}/goals/{goal}/datapoints.json"
            data = {
                "auth_token": AUTH_TOKEN,
                "value": value,
                "comment": comment,
                "daystamp": daystamp
            }
            response = requests.post(url, data=data)

            if response.status_code == 200:
                print(f"✅ Updated {goal} on {daystamp}")
            else:
                print(f"⚠️ Failed to update {goal}: {response.text}")

        except ValueError as e:
            print(f"⚠️ Skipping malformed line: {line}")

client.run(DISCORD_TOKEN)
4 Likes