Archived in favour of a monorepo: clique-discord/clique.
This is the collector service for Clique. It is responsible for collecting metadata on messages from Discord, and storing them in a PostgreSQL database.
The service requires a PostgreSQL database to store messages in, and a Discord bot token to recieve messages from Discord.
Install PostgreSQL if you haven't already, and create a database and user for the service.
-
Connect to the server as the
postgres
user (eg.psql -U postgres
). -
Create a new database:
CREATE DATABASE clique;
-
Create a new user:
CREATE USER clique_collector WITH ENCRYPTED PASSWORD 'password-goes-here';
. -
Grant the user access to the database:
GRANT ALL ON DATABASE clique TO clique_collector;
You'll need to create a Discord application with a bot in order for the service to connect to Discord and recieve messages.
- Go to the Discord Developer portal and press "New Application".
- Once you've created an application, go to "Bot" and create a bot.
- Copy the token.
The config file uses the INI format and contains the URL for the database, and the token for the Discord bot.
-
This should be a file named
config.ini
, in the directory where you will be running the service. -
Add the following to the file (replace the Discord token and Postgres password as appropriate):
[clique-collector] discord_token = DISCORD.TOKEN.GOES.HERE postgres_url = postgres://clique_collector:password-goes-here-jpYU@localhost:5432/clique
You can either download an executable (this step) or compile your own (the next step). You may want to compile your own for security reasons, or if there is not a pre-compiled executable for your operating system.
-
Download the executable (or click here):
wget https://github.com/clique-discord/collector/releases/latest/download/clique-collector-linux -qO clique-collector
-
Make the file executable:
chmod +x clique-collector
-
Download the executable (or click here):
wget https://github.com/clique-discord/collector/releases/latest/download/clique-collector-macos -qO clique-collector
-
Make the file executable:
chmod +x clique-collector
-
Download the executable with Power shell (or click here):
iwr -outf clique-collector.exe https://github.com/clique-discord/collector/releases/latest/download/clique-collector.exe
If you don't want to use a pre-compiled executable, you can compile one using Rust:
- Install Rust.
- Run
cargo build --release
in the same directory as this README. - Your binary will be at
target/release/clique-collector
.
This is as simple as executing the binary with your config.ini
in the current
working directory, for example ./clique-collector
. You may also wish to set
it up with systemd
or another process management system.
The service will create a table name messages
in the database, with the
following schema:
Column | Type | Nullable? | Description |
---|---|---|---|
id |
bigint |
no | The Discord ID of the message. Primary key. |
guild |
bigint |
no | The ID of the guild the message was sent in. |
author |
bigint |
no | The ID of the author of the message. |
channel |
bigint |
no | The ID of the channel the message was sent in. |
reply_to |
bigint |
yes | The ID of the author of the message this is a reply to, if any. |
timestamp |
timestamp without time zone |
no | When the message was sent. |