nyxx/README.md
2018-09-15 15:17:12 +02:00

3.4 KiB



Build Status Pub documentation

Simple, robust framework for creating discord bots for Dart language.
This repo is fork of Hackzzila's nyx - extended with new functionality, rewritten backend, many bug fixes and applied pending pull requests.


Stable release

Starting from version 1.0.0 of nyxx, library requires Dart 2.0+. You can use stable release or dev sdk.

Features

  • Commands framework included
    A fast way to create a bot with command support. Implementing the framework is simple - and everything is done automatically.
  • Cross Platform
    Nyxx works on the command line, in the browser, and on mobile devices.
  • Fine Control
    Nyxx allows you to control every outgoing HTTP request or WebSocket message.
  • Internal Sharding
    Nyxx automatically spawns shards for your bot, but you can override this and spawn a custom number of shards. Internal sharding means that all of your bots shards are managed in one script, and there is no need for communication between shards.
  • Complete
    Nyxx supports nearly all Discord API endpoints.

Sample

Basic usage:

void main() {
  discord.Client bot =
      new discord.Client(Platform.environment['DISCORD_TOKEN']);

  bot.onReady.listen((discord.ReadyEvent e) {
    print("Ready!");
  });

  bot.onMessage.listen((discord.MessageEvent e) {
    if (e.message.content == "!ping") {
      e.message.channel.sendMessage(content: "Pong!");
    }
  });
}

Commands:

void main() {
  nyxx.Nyxx bot = nyxx.Nyxx(Platform.environment['DISCORD_TOKEN']);
  command.CommandsFramework('!', bot)
    ..admins = [nyxx.Snowflake("302359032612651009")]
    ..registerLibraryCommands();
}

@command.Command(name: "single")
Future<void> single(command.CommandContext context) async {
  await context.reply(content: "WORKING");
}

@command.Module("ping")
class PongCommand extends command.CommandContext {
  @command.Command()
  @command.Help("Pong!", usage: "ping")
  Future<void> run() async {
    await reply(content: "Pong!");
  }
  
  @command.Command(name: "subcommand")
  Future<void> run() async {
   await reply(content: "\\cmd");
  }
}

Documentation, help and examples

Discord API docs

Discord API documentation features rich descriptions about all topics that nyxx covers.

Discord API Guild

Unofficial guild for Discord Bot developers. To get help with nyxx check #dart_nyxx channel.

Dartdocs

The dartdocs page will always have the documentation for the latest release.

Dev docs

You can read about upcoming changes to the library on my website.

Wiki

Wiki documentation are designed to match the latest Nyxx release.