sendMessage method Null safety

  1. @override
Future<Message> sendMessage(
  1. MessageBuilder builder
)
override

Sends message to channel. Performs toString() on thing passed to content. Allows to send embeds with embed field.

await channel.sendMessage(content: "Very nice message!");

Can be used in combination with Emoji. Just run toString() on Emoji instance:

final emoji = guild.emojis.findOne((e) => e.name.startsWith("dart"));
await channel.send(content: "Dart is superb! ${emoji.toString()}");

Embeds can be sent very easily:

var embed = EmbedBuilder()
  ..title = "Example Title"
  ..addField(name: "Memory usage", value: "${ProcessInfo.currentRss / 1024 / 1024}MB");

await channel.sendMessage(embed: embed);

Method also allows to send file and optional content with embed. Use expandAttachment(String file) method to expand file names in embed

await channel.sendMessage(files: [new File("kitten.png"), new File("kitten.jpg")], content: "Kittens ^-^"]);
var embed = new nyxx.EmbedBuilder()
  ..title = "Example Title"
  ..thumbnailUrl = "${attach("kitten.jpg")}";

channel.sendMessage(files: [new File("kitten.jpg")], embed: embed, content: "HEJKA!");

Implementation

@override
Future<Message> sendMessage(MessageBuilder builder);