Skip to content
/ mothy Public
forked from jamesbt365/mothy
Notifications You must be signed in to change notification settings

Kuuuube/mothy

 
 

Repository files navigation

Mothy

A small Discord bot that i'm using to learn rust. The Code is questionable, I know.

This bot is created with poise which is a Discord API wrapper.

Setup

Postgres

  1. Install postgresql

  2. Switch user:

    sudo su - postgres
    
  3. Init the db:

    initdb -D /var/lib/postgres/data
    

    Note: On Debian and Ubuntu this command may not be available by default due to opinionated packaging that goes against postgres's documentation.

    The database may already be set up and ready to go after installing the package. But if not, add the following to ~/.bashrc and source ~/.bashrc:

    export PATH=$PATH:/usr/lib/postgresql/{version}/bin/
    
  4. Start the database server:

    pg_ctl -D /var/lib/postgres/data -l logfile start
    

    Note: If you get FATAL: could not create lock file, the directory /run/postgresql may not be created. Run the following to create and set ownership of it:

    sudo mkdir /run/postgresql
    sudo chown postgres /run/postgresql
    
  5. (Optional) If you want to use a database under a non-default name, run the following (replace postgresmothy with whatever you prefer):

    sudo su - postgres
    psql
    CREATE DATABASE postgresmothy;
    

    Verify it has been created with:

    SELECT datname FROM pg_database WHERE datistemplate = false;
    
  6. Exit the postgres user with exit

Sqlx

  1. Install sqlx-cli

    cargo install sqlx-cli
    

    Note: On Debian and Ubuntu try this if there are weird openssl errors:

    apt-get install libssl-dev pkg-config
    
  2. Copy .end_template to .env and input the following:

    DATABASE_URL=postgres://postgres@localhost/postgres
    

    Note: Replace the postgres on the end with whatever your database name is if your are not using the default.

  3. Init database:

    cargo sqlx migrate run
    

    Note: Debian and Ubuntu REALLY REALLY REALLY want your database to have a password and will beat you over the head with errors until you just give up and set one. Here's how to do that:

    sudo -u postgres psql
    ALTER USER postgres PASSWORD '{password}'; # replace {password} with your password
    

    Edit the DATABASE_URL in .env to include the password (replace {password} with your password):

    DATABASE_URL=postgres://postgres:{password}@localhost/postgres
    

Misc

  1. Run fetch_moth_data.sh to grab data for the moth species integrations.

Mothy

  1. Add your bot token to MOTHY_TOKEN in .env.

  2. Invite the bot somewhere

    Example (replace {BOT_ID_HERE}): https://discord.com/oauth2/authorize?client_id={BOT_ID_HERE}&scope=bot%20applications.commands&permissions=8

  3. Run mregister to register commands or mdevregister if DEV_COMMANDS=true is set in .env.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

No packages published

Languages

  • Rust 99.4%
  • Shell 0.6%