Bot.ts
  • Introduction
  • Installation
  • Configuration
  • Migrate to v9
  • Troubleshooting
  • Command line
    • CLI Overview
    • Docker
    • Build
    • Start
    • Format
    • Lint
    • Test
    • Update
    • Readme
    • Final
  • Usage
    • Command
    • Listener
    • Button
    • Namespace
    • Cron
    • Logger
    • Paginator
    • Database
    • Caching
    • Custom types
  • Native commands
    • Eval
    • Help
    • Database
    • Terminal
    • Turn
    • Info
  • Command examples
    • Prefix
  • Utilities
    • Texts
    • Paths and URLs
    • Dates and durations
    • Special events
    • Other
  • Deployment
    • Production
    • Development
  • Contributing
    • Regulations
    • Coding Style
  • Annexes
    • Discord Support
Powered by GitBook
On this page
  • Description
  • Command Pattern
  • Automatic Replacement
  • Code Blocks
  • Arguments
  • Examples
  • Basic Query
  • Query with Placeholders
  • Formatted Query
  • Subcommands
  • Plan
  • Annexes

Was this helpful?

  1. Native commands

Database

Advanced database command for executing SQL queries and managing database plans.

Description

The database command allows the bot owner to run SQL queries directly on the bot's database. This can be useful for testing, debugging, or managing data within the server.

Command Pattern

In the Discord server where you invited the bot, use the following command pattern in a channel accessible by the bot.

.database <query>

For example:

.database SELECT * FROM users

Automatic Replacement

Certain placeholders in the SQL query are automatically replaced:

  • $guild -> Guild ID

  • $channel -> Channel ID

  • $me -> Author ID

Mentions (e.g., <@123456789012345678>) are replaced with their respective IDs, and table names are automatically quoted.

Code Blocks

You can also use code blocks to format your SQL query:

.database ```sql
SELECT * FROM users WHERE id = $me
```

Arguments

Examples

Basic Query

Run a simple SQL query:

.database SELECT * FROM users

Query with Placeholders

Use placeholders for dynamic data:

.database SELECT * FROM messages WHERE author_id = $me

Formatted Query

Use code blocks for better readability:

.database ```sql
SELECT * FROM messages
WHERE channel_id = $channel
AND guild_id = $guild
```

Subcommands

Plan

The plan subcommand shows the database schema, including the table names, column types, and default values.

Usage

.database plan

Aliases

  • tables

  • schema

  • list

  • view

Example

.database plan

Annexes

PreviousHelpNextTerminal

Last updated 6 months ago

Was this helpful?

Check the / section if you have a problem.

Command file
Command
Arguments