description |
---|
Advanced database command for executing SQL queries and managing database plans. |
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.
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
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.
You can also use code blocks to format your SQL query:
.database ```sql
SELECT * FROM users WHERE id = $me
```
{% hint style="warning" %} Check the Command/Arguments section if you have a problem. {% endhint %}
Run a simple SQL query:
.database SELECT * FROM users
Use placeholders for dynamic data:
.database SELECT * FROM messages WHERE author_id = $me
Use code blocks for better readability:
.database ```sql
SELECT * FROM messages
WHERE channel_id = $channel
AND guild_id = $guild
```
The plan
subcommand shows the database schema, including the table names, column types, and default values.
.database plan
tables
schema
list
view
.database plan