Skip to content

Discord bot running chdb/ClickHouse queries, powered by Deta.space

License

Notifications You must be signed in to change notification settings

chdb-io/chdb-discord-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chdb-discord-bot

Serverless bot running SQL queries using chDB public servers or any ClickHouse HTTP/S APIs

Features

  • /ping - a simple command that tells you the bot's latency.
  • /query <query> [format] - a command that queries chDB API (ClickHouse).
  • A status message Listening to /query! | chDB via scheduled actions.
  • And you can easily create and add more commands yourself!

Requirements

  • Discord Application: Create an app for FREE at Discord Developer Portal.
  • Deta Space account: Create an account for FREE at Deta Space, username + password.
  • chDB API URL: Use the public service, or point at your HTTP/S chDB/ClickHouse compatible API..

Running Online

  1. Create a new deta.space application:
    1. Install the Space CLI.
    2. Clone this repository.
    3. Make sure you're in the project folder: $cd <folder>
    4. Create a space app: $space new
    5. Push the space app: $space push
  2. Enter the environment variables (Space App Settings ➔ Configuration).
    • DISCORD_APPLICATION_ID - Your discord app's ID.
    • DISCORD_PUBLIC_KEY - Your discord app's public key.
    • DISCORD_BOT_TOKEN - Your bot's token.
    • CHDB_API - Your ClickHouse HTTP/S API (optional)
    • Other environment variables are optional.
  3. Set Interactions Endpoint URL to <micro_url>/bot/interactions.
    • This is located in: https://discord.com/developers/applications/{application_id}/information
    • A Micro URL looks like this: https://chdbdiscordbot-xxxxxxx.deta.app
  4. Visit <micro_url>/bot/api/dash/<discord_bot_token> to register the slash commands for the first time.
    • If this fails, use the register.sh script with your DISCORD_APPLICATION_ID and DISCORD_BOT_TOKEN
  5. Run /ping to make sure it's working! Enjoy!

Test Commands

chdb-discord-bot

Powered by Deta.space

This Discord bot is SERVERLESS which means it can run for FREE and be ALWAYS online on Deta Space!

Code forked and adapted from chatgpt-discord-bot

Links and Resources

About

Discord bot running chdb/ClickHouse queries, powered by Deta.space

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project