Skip to content

vldcreation/discord-bot-node-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database Configuration

This application can connect to either a PostgreSQL or MySQL database. Configure the connection using the following environment variables:

  • DB_DRIVER: Specifies the database driver. Use postgres for PostgreSQL or mysql for MySQL. Defaults to postgres.
  • DB_HOST: The hostname or IP address of your database server. (e.g., localhost or an IP)
  • DB_PORT: The port number for your database server. (e.g., 5432 for PostgreSQL, 3306 for MySQL)
  • DB_USER: The username for connecting to the database.
  • DB_PASSWORD: The password for the database user.
  • DB_NAME: The name of the database to connect to.
  • DB_SSLMODE: (Optional) SSL mode for the database connection.
    • For PostgreSQL: e.g., require, prefer, allow, disable. Refer to pg documentation for details.
    • For MySQL: Set to true or false (or provide SSL options object structure if needed, though current adapter uses basic boolean). Refer to mysql2 documentation.

You can set these environment variables in a .env file in the root of the project. A dev.env.sample is provided as a template.

New Commands

/connect

Connects the bot to the configured database based on the environment variables. Usage: /connect Replies with a success or failure message.

/check-broken-invoice

Checks for potentially broken invoices within a specified date range. This command requires an active database connection (use /connect first). Usage: /check-broken-invoice start_date:YYYY-MM-DD end_date:YYYY-MM-DD

  • start_date: The start date for the period to check (format: YYYY-MM-DD).
  • end_date: The end date for the period to check (format: YYYY-MM-DD).

The command will return:

  1. A list of 'UNPAID' invoices created within the date range that do not have any associated invoice items.
  2. A list of 'UNPAID' invoice items (for 'DROPOFF' or 'PICKUP' type invoices) created within the date range that do not have any associated shipment records.

/disconnect

Disconnects the bot from the current database if a connection is active. Usage: /disconnect Replies with a success message or an informational message if not connected.

/clear-chat

Clears messages from the current channel. Requires "Manage Messages" permission. Usage: /clear-chat <subcommand>

Subcommands:

  • all

    • Clears all messages in the current channel.
    • Note: Messages older than 2 weeks are deleted individually, which can be slow and is subject to stricter rate limits. Discord API limits bulk deletion to messages newer than 2 weeks.
    • Usage: /clear-chat all
  • fixed

    • Clears a specific number of the most recent messages.
    • Parameters:
      • number (Integer, Required): The number of messages to delete (1-1000).
    • Usage: /clear-chat fixed number:50
  • range

    • Clears messages within a specified date range.
    • Parameters:
      • start_date (String, Required): The start date of the range. Accepts YYYY-MM-DD format (e.g., "2023-01-01") or relative terms like "1d" (1 day ago), "today".
      • end_date (String, Optional): The end date of the range. Accepts YYYY-MM-DD format or relative terms. Defaults to the current time if not provided.
    • Usage examples:
      • /clear-chat range start_date:2023-10-01 end_date:2023-10-05
      • /clear-chat range start_date:2d (clears messages from 2 days ago until now)
      • /clear-chat range start_date:2023-11-01 (clears messages from 2023-11-01 until now)

Discord BOT for Virtual GF

Discover Feature

  • Chatbot AI
  • Generate Image

How To Install

About

Discord Bot integrate with open AI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors