Mercury

A Dart wrapper for the Discord API. Feel free to contribute!

Documentation is available here, and examples can be found in the example directory.

Features

  • Speedy (built upon the latest versions of the Dart SDK and web APIs)
  • Small dependency tree (only one direct dependency - w_transport, for both WebSocket and REST // five development dependencies)
  • Predictable - robust and well-defined type checks included with all models
  • Multiplatform - runs anywhere Dart VM (Web support soon) does

Example

A quick example of the client in action: (More examples available in the example folder)

import 'package:mercury/mercury.dart' as discord;

import 'package:w_transport/vm.dart' show vmTransportPlatform;
// Dart for Web: import 'package:w_transport/browser.dart' show browserTransportPlatform;

void main() {
  var client = new discord.Session(vmTransportPlatform /* dart for web: browserTransportPlatform */);
  client.setToken('MY TOKEN', discord.TokenType.Bot)
  client.dispatcher.messageCreate.listen((discord.Message msg) async {
    print('Received message with ID ${msg.id} (Channel ID ${msg.channel.id})');
    print('Content: ${msg.content}');
    if (msg.content == '!ping') {
      await msg.channel.createMessage('Pong!');
    }
  });
  client.dispatcher.ready.listen((empty) {
    print('Ready');
  });
  client.start();
}

Contributing

Contributing guidelines:

  • Please use dartfmt and follow Dart's standard formatting rules for all your contributions
  • Please follow the naming conventions already laid out in the project
  • The tests haven't been fully written yet, so you can run pub run tool/dev_bot.dart (check file for the environment variables to set) to run a dev instance/test client of Mercury.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Libraries

mercury
A Dart wrapper for the Discord API