sendMessage abstract method

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

Sends message to channel. Allows to send embeds with MessageBuilder.embed() method.

await channel.sendMessage(MessageBuilder.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.sendMessage(MessageBuilder.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(MessageBuilder.embed(embed));

Method also allows to send multiple files and optional content with embed.

await event.message.channel.sendMessage(
  MessageBuilder.files(
    [
      AttachmentBuilder.file(
        File("kitten.png"),
        name: "kitten.png",
      ),
    ],
  )..content = "Kittens ^-^",
);

You can refer the sent attachments in embeds by prefixing them with attachment://:

var embed = EmbedBuilder()
  ..title = "Example Title"
  ..thumbnailUrl = "attachment://kitten.jpg";

await event.message.channel.sendMessage(
  MessageBuilder.files(
    [
      AttachmentBuilder.file(
        File("kitten.jpg"),
      ),
    ],
  )
    ..embeds = [embed]
    ..content = "HEJKA!",
);

Implementation

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