Serverless bot running SQL queries using chDB public servers or any ClickHouse HTTP/S APIs
/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!
- 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..
- Create a new deta.space application:
- Install the Space CLI.
- Clone this repository.
- Make sure you're in the project folder:
$cd <folder>
- Create a space app:
$space new
- Push the space app:
$space push
- 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.
- 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
- This is located in:
- 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 yourDISCORD_APPLICATION_ID
andDISCORD_BOT_TOKEN
- If this fails, use the
- Run
/ping
to make sure it's working! Enjoy!
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
- Deta Space Documentation: https://deta.space/docs
- Discohook Discord: https://discord.gg/xEEpJvE9py
- Discord API Documentation: https://discord.com/developers/docs