Installation

Before embarking on this crazy discord adventure, you will need to follow the steps outlined below to set up a clean and healthy project.


Prerequisites

Please make sure you have the following tools installed on your machine before you start.

Dart lang

The Mineral framework has been developed entirely in the Dart programming language, so you will need to install it in your development environment first. In order to best install it, please refer to the official documentation.

Note

The version of the Dart language sdk must be at least ^3.5.2.


Setup new project

From the CLI

You can use the Mineral CLI to create a new project.

Follow the steps below to install the CLI.

dart pub global activate mineral_cli [version]

cd path/to/your/projects
mineral create my_project
Note

More details about the CLI can be found in the command line section.


From scratch

Use the following command to start a new blank Dart project.

dart create my_project

After creating the project, you will need to add the Mineral framework to your pubspec.yaml file.

dependencies:
  mineral: ^4.0.0-dev.11
  mineral_cache: ^1.0.0-dev.4
Note

Please verify the lasted version of the core and cache packages directly on registry.

Then run the following command to install the dependencies.

dart pub get

Make sure you have the following minimal structure in your project. The .env file is not created by default when you start a new Dart project, don’t forget to create it.

├── bin
│  └── main.dart

├── pubspec.yaml
└── .env

Application

The main.dart file is the entry point of your application. This is where you will start your bot.

void main(_, port) async {
  final client = ClientBuilder()
    .setHmrDevPort(port)
    .build();

  await client.init();
}

To check that your application is working properly, we recommend that you use the ready event.

void main(_, port) async {
  final client = ClientBuilder()
    .setHmrDevPort(port)
    .build();

  client.events.ready((Bot bot) {
    client.logger.info('${bot.username} is ready ! 🚀');
  });

  await client.init();
}

Running the application

Finally, you can run your application with the following command.

dart run bin/main.dart