selene 0.3.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 0

Selene #

Travis Pub

An unofficial Dart client for the Discord API.

  • Features:
    • REST and WebSocket APIs loosely coupled, so you can write your own implementation (or use the default)
    • Strongly-typed mapped entities with OOP navigational properties
  • Planned:
    • Sending and receiving voice
    • Automatic WebSocket connection recovering and restarting
    • Sharding support (and autosharding)

Usage #

You can browse the example folder for some basic examples. The developer bot instance, test/selene_test.dart, is a comprehensive test of the latest functionality.

Installation #

View the package listing for installation instructions.
You will need Dart SDK 2.0.0-dev.55.0 or above.

Documentation #

Documentation is generated with dartdoc, simply using the dartdoc command with no parameters.
Hosted documentation is available here.

Dependencies #

Copyright (c) 2018 sarcasmloading under the MIT License. All rights reserved.

0.3.2 #

Changed #

  • Minor cleanup

Fixed #

  • Documentation not appearing for several classes

0.3.1 #

Added #

  • Finally implemented EmbedBuilder class and appropriate parameters on TextChannel.sendMessage

Fixed #

  • Fixed breaking issue: NRE thrown on Message.member

0.3.0 #

Changed #

  • Major: Overhauled how entities are initialised and cached
  • Cleaned up library as a whole, fixed a lot of issues
  • EntityCache has been renamed to ClientState

Breaking Changes #

  • ClientState.self has been renamed to ClientState.currentUser

Added #

  • Documented User, PermissionOverwrite and GuildRole
  • Documented numerous minor methods and objects
  • Shortcuts on Client to numerous ClientState fields

Removed #

  • Reaction support has been removed temporarily
    • Will likely return during release cycle 0.3.2 - 0.3.5

0.2.1 #

Changed #

  • Converted _Dispatcher to public Dispatcher for documentation access

v0.2 #

Fixed #

  • Fixed null fields on client
  • Fixed duplicate roles appearing after a guild update
  • Fixed random crashing when attempting to update a role

Added #

  • Added more events to the dispatcher type

Changed #

  • Reconfigured how channels are stored

Removed #

  • Removed VM/web options due to internal technical restraints
    • This support will return in a future update

example/selene_example.dart

import 'dart:async';

import 'package:logging/logging.dart';
import 'package:selene/selene.dart' as discord;

void main() {
  runBot();
}

Future runBot() async {
  // Create our client instance
  var client = new discord.Client();

  // Listen for log events
  Logger.root.onRecord.listen((LogRecord record) {
    print('[${record.loggerName}] ${record.level.name}: ${record.time}: ${record
        .message}');
  });

  // Event Guidelines
  // - You MUST catch exceptions thrown in your event handlers. Due to Dart limitations,
  // the library CANNOT catch exceptions thrown from stream subscriptions.
  // If you don't catch them, they will KILL the WebSocket connection and the bot
  // will go offline!

  // Listen to the message created event
  client.dispatcher.onMessageReceive.listen((discord.Message message) async {
    if (message.content == '!ping') {
      // Pong
      await message.channel.sendMessage(
          content:
              'Pong!'); // sendMessage takes either content, embed or both. At least one must be supplied.
    }

    if (message.content == '!whoareyou' || message.content == '!bot') {
      var bot = client.state.currentUser; // Get the client's current user
      // Create an embed
      var embed = new discord.EmbedBuilder();
      embed.author = new discord.EmbedAuthorBuilder.fromUser(
          bot); // Fill in properties from user
      embed.description =
          "Hello there! I am ${bot.username}#${bot.discriminator}!";
      await message.channel
          .sendMessage(embed: embed); // Construct embed
    }
  });

  // Login and authorize
  client.login(
    'MyToken', /* type: 'Bot' -- This parameter is optional and defaults to Bot. */
  );

  // Initiate WebSocket connection
  await client.start();

  // Client will automatically block the thread
}

Use this package as a library

1. Depend on it

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


dependencies:
  selene: ^0.3.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


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

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.55.0 <2.0.0