nyxx 0.30.0



Build Status Pub documentation

Simple, robust framework for creating discord bots for Dart language. This is fork of Hackzzila's nyx.


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.
  • Complete
    Nyxx supports nearly all Discord API endpoints.

Sample #

Basic usage:

void main() {
  var bot = Nyxx(Platform.environment['DISCORD_TOKEN']);

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

Commands:

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

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

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.

0.3.0 #

Tue 07.02.2019

This version drops support for Dart SDK 1.x; Nyxx now only supports Dart 2.0+ including dev sdk.

Changelog can be incomplete - it's hard to track changes across few months

  • Features added
    • SUPPORT FOR DART 2.0+
    • ADDED SUPPORT FOR VOICE via Lavalink
    • PERMISSIONS OVERHAUL
      • Proper permissing handling
    • COMMANDS FRAMEWORK REWRITTEN
      • Dispatch pipe is completely rewritten. Bot should operate about 2-8x faster
      • Allowed to declare single method commands without using classes
      • Added support for specify custom restrictions to commands handlers
      • Classes now have to be annotated with Module instead of Command
      • Remainder can now colled data to List<String> or String
      • Added Preprocessor and Posprocessor
      • Removed help system
    • COMMANDS PARSER
      • Allows to define simple commands handlers
    • Nyxx can be now used in browser
    • Many additions to Member and User classes
    • Changed internal library structure
    • Implemented Iterable for Channel to query messages
    • Added typing event per channel
    • Using v7 api endpoint
    • Added support for zlib compressed gateway payload
    • Added enpoints for Guild, Emoji, Role, Member
    • Added utils module
    • Allowed to download attachments. (Downloadable interface)
    • Implemented new Discord features (Priority speaker, Slowmode)
    • Added DiscordColor class
    • Added Binder util
    • Added Cache
    • Added MessageBuilder
    • Added interfaces Downloadable, Mentionable, Debugable, Disposable, GuildEntity
  • Bug fixes
    • Lowered memory usage
    • Websocket fixed
    • Fixed Emijis comparing
    • Fixed searchin in Emojis unicode
    • Code cleanup and style fixes
    • Proper error handling for CommandsFramework
    • Gateway fixes
    • Object deserializing fixes
    • Memory and performance improvements
    • Random null exceptions
    • Emojis CDN fixes
    • Fixes ratelimitter
  • Changes
    • Docs are rewritten
    • Faster deserialization
    • Embed builders rewritten
    • Removed autosharding.
    • Every object which has id is now subclass of SnowflakeEntity.
    • Snowflakes are default id entities
    • Internal nyxx API changes
    • Cooldown cache rewritten
    • Presence sending fixes
    • Title is not required for EmbedBuilder
    • Removed uneccessary dependencies

0.24.0 #

Tue 03.08.2018

  • Changes

    • nyxx now supports Dart 2.0
    • Added Interactivity module
    • Added few methods to CommandContext
    • Rewritten CooldownCache
  • Bug fixes

    • Fixed Command help generating error
    • Fixed Emojis equals operator

0.23.1 #

Tue 31.07.2018

  • Bug fixes
    • Fixed MessageDeleteEvent deserializing error
    • Fixed checking for channel nsfw for CommandsFramework

0.23.0 #

Mon 30.07.2018

  • New features
    • Support for services - DEPENDENCY INJECTION
    • Support for type parsing
    • Logging support
    • Listener for messages for channel
    • Automatic registering Services and Commands
    • Remainder annotation which captures all remaining text
    • Permissions are now READ/WRITE - added PermissionsBuilder
    • Checking for topics and if channel is nsfw for commands
  • Bug fixes
    • Fixed error throwing
    • Text in quotes is one String
    • Fixed StreamControllers to be broadcast
    • Removed unnecessary fields from DMChannel and GroupDMChannel
    • Big performance improvement of CommandFramework
    • Fixed Permissions opcode
    • delay() changed to nextMessage()
  • Deprecations
    • Deprecated browser target
    • Removed MirrorsCommandFramework and InstanceCommandFramework

0.22.1 #

Wed 11.07.2018

  • Bug fixes
    • Fixed bug with sending Emoji. toString() now return proper representation ready to send via message
  • New features
    • Searching in EmojisUnicode is now handled by future.
    • toString() in User, Channel, Role now returns mention instead of content, name etc.

0.22.0 #

Wed 11.07.2018

  • Bug fixes
    • Next serialization bug fixes
  • New features
    • Added support for audit logs
    • Searching in EmojisUnicode based on shortcode

0.21.5 #

Fri 09.07.2018

  • Bug fixes
    • Fixed embed serialization

0.21.4 #

Fri 09.07.2018

  • Bug fixes
    • Fixed embed serialization

0.21.3 #

Fri 08.07.2018

  • Bug fixes
    • Fixed embed serialization
  • Added few Docs

0.21.2 #

Fri 06.07.2018

  • Bug fixes
    • Added overrides
    • Implemented hashCode
    • Fixed return type for delay() in Command class

0.21.1 #

Fri 06.07.2018

  • Bug fixes
    • Fixed constructors in MessageChannel and TextChannel

0.21.0 #

Fri 06.07.2018

  • New features
    • Support for sending files, attaching files in embed
    • Added missing gateway events
    • Replaced String ids with Snowflake type
  • Bug fixes

example/example.dart

import 'package:nyxx/Vm.dart';
import 'package:nyxx/nyxx.dart';
import 'package:nyxx/commands.dart';

import 'dart:io';
import 'dart:async';

// Example service which can be injected into your command handler
class Service {
  String data;

  Service(this.data);
}

// Main function
void main() {
  configureNyxxForVM();

  // Create new bot instance
  Nyxx bot = Nyxx(Platform.environment['DISCORD_TOKEN']);

  // Register new command handler.
  // It registers your services and adds command to registry.
  CommandsFramework(bot, prefix: '!', admins: [Snowflake("302359032612651009")])
    ..registerServices([Service("Siema")])
    ..discoverCommands();
}

@Command("alias", aliases: ['aaa'])
Future<void> aliasCmd(CommandContext ctx, String name) async {
  await ctx.reply(content: name);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  nyxx: ^0.30.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:nyxx/nyxx.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
58
Health:
Code health derived from static analysis. [more]
37
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Aug 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:nyxx/nyxx.dart with components: io, isolate.

Health suggestions

Fix lib/src/nyxx/internal/_EventController.dart. (-16.93 points)

Analysis of lib/src/nyxx/internal/_EventController.dart reported 37 hints, including:

line 236 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 237 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 238 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 239 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 240 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

Fix lib/src/nyxx/objects/guild/Guild.dart. (-7.24 points)

Analysis of lib/src/nyxx/objects/guild/Guild.dart reported 15 hints, including:

line 144 col 13: DO use curly braces for all flow control structures.

line 146 col 13: DO use curly braces for all flow control structures.

line 149 col 13: DO use curly braces for all flow control structures.

line 173 col 11: DO use curly braces for all flow control structures.

line 184 col 15: DO use curly braces for all flow control structures.

Fix lib/src/commands/CommandsFramework.dart. (-6.31 points)

Analysis of lib/src/commands/CommandsFramework.dart reported 13 hints, including:

line 13 col 5: DO use curly braces for all flow control structures.

line 14 col 7: DO use curly braces for all flow control structures.

line 59 col 9: DO use curly braces for all flow control structures.

line 123 col 11: DO use curly braces for all flow control structures.

line 195 col 32: Use isNotEmpty instead of length

Fix additional 41 files with analysis or formatting issues. (-66.76 points)

Additional issues in the following files:

  • lib/src/nyxx/events/MessageEvents.dart (13 hints)
  • lib/src/nyxx/internal/Http.dart (10 hints)
  • lib/src/nyxx/objects/embed/Embed.dart (9 hints)
  • lib/src/nyxx/objects/channel/GuildChannel.dart (8 hints)
  • lib/src/utils/Interactivity.dart (8 hints)
  • lib/src/lavalink/LavalinkPlayer.dart (6 hints)
  • lib/src/lavalink/LavalinkManager.dart (5 hints)
  • lib/src/nyxx/Nyxx.dart (5 hints)
  • lib/src/nyxx/Shard.dart (5 hints)
  • lib/src/nyxx/builders/AttachmentBuilder.dart (5 hints)
  • lib/src/nyxx/builders/EmbedBuilder.dart (5 hints)
  • lib/src/nyxx/objects/message/Message.dart (5 hints)
  • lib/src/commands/CommandContext.dart (4 hints)
  • lib/src/nyxx/builders/GuildBuilder.dart (4 hints)
  • lib/src/nyxx/objects/auditlogs/AuditLog.dart (4 hints)
  • lib/src/nyxx/objects/user/Presence.dart (4 hints)
  • lib/src/nyxx/objects/user/Member.dart (3 hints)
  • lib/src/commands/CommandsParser.dart (2 hints)
  • lib/src/nyxx/builders/EmbedFieldBuilder.dart (2 hints)
  • lib/src/nyxx/builders/PermissionsBuilder.dart (2 hints)
  • lib/src/nyxx/events/GuildEvents.dart (2 hints)
  • lib/src/nyxx/events/PresenceUpdateEvent.dart (2 hints)
  • lib/src/nyxx/objects/ISend.dart (2 hints)
  • lib/src/nyxx/objects/guild/Ban.dart (2 hints)
  • lib/src/nyxx/objects/guild/Role.dart (2 hints)
  • lib/src/nyxx/objects/message/Reaction.dart (2 hints)
  • lib/src/nyxx/objects/voice/VoiceState.dart (2 hints)
  • lib/src/nyxx/builders/EmbedAuthorBuilder.dart (1 hint)
  • lib/src/nyxx/builders/EmbedFooterBuilder.dart (1 hint)
  • lib/src/nyxx/builders/MessageBuilder.dart (1 hint)
  • lib/src/nyxx/events/ChannelEvents.dart (1 hint)
  • lib/src/nyxx/events/VoiceStateUpdateEvent.dart (1 hint)
  • lib/src/nyxx/internal/Cache.dart (1 hint)
  • lib/src/nyxx/objects/DiscordColor.dart (1 hint)
  • lib/src/nyxx/objects/guild/ClientUser.dart (1 hint)
  • lib/src/nyxx/objects/guild/Status.dart (1 hint)
  • lib/src/nyxx/objects/user/User.dart (1 hint)
  • lib/src/utils/Permissions.dart (1 hint)
  • lib/src/utils/Util.dart (1 hint)
  • lib/src/nyxx/objects/guild/Webhook.dart (Run dartfmt to format lib/src/nyxx/objects/guild/Webhook.dart.)
  • lib/src/nyxx/objects/message/GuildEmoji.dart (Run dartfmt to format lib/src/nyxx/objects/message/GuildEmoji.dart.)

Maintenance issues and suggestions

Issue tracker URL doesn't exist. (-10 points)

At the time of the analysis the issue_tracker field https://github.com/l7ssha/nyxx/issue was unreachable.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
logging ^0.11.3+2 0.11.3+2
w_transport ^3.2.8 3.2.8
Transitive dependencies
args 1.5.2
async 2.3.0
charcode 1.1.2
cli_repl 0.2.0+1
collection 1.14.12
colorize 2.0.0
dart2_constant 1.0.2+dart2
fluri 1.2.5
glob 1.1.7
http 0.12.0+2
http_parser 3.1.3
intl 0.15.8
js 0.6.1+1
matcher 0.12.5
meta 1.1.7
mime 0.9.6+3
package_config 1.1.0
package_resolver 1.0.10
path 1.6.4
pedantic 1.8.0+1
quiver 2.0.5
sass 1.22.10
sockjs_client 0.3.5
sockjs_client_wrapper 1.0.11
source_maps 0.10.8
source_span 1.5.5
stack_trace 1.9.3
stream_transform 0.0.19
string_scanner 1.0.5
term_glyph 1.1.0
tuple 1.0.2
typed_data 1.1.6
w_common 1.20.1
watcher 0.9.7+12
Dev dependencies
analyzer any
dart_style any