execute method

Future<void> execute({
  1. String? content,
  2. String? username,
  3. String? avatarUrl,
  4. bool? tts,
  5. List<EmbedBuilder>? embeds,
  6. List<RowBuilder>? components,
  7. bool? suppressEmbed,
})

Send a message from the webhook

Example :

await webhook.execute(content: 'Hello World !');

Implementation

Future<void> execute ({ String? content, String? username, String? avatarUrl, bool? tts, List<EmbedBuilder>? embeds, List<RowBuilder>? components, bool? suppressEmbed }) async {

  List<dynamic> embedList = [];
  if (embeds != null) {
    for (EmbedBuilder element in embeds) {
      embedList.add(element.toJson());
    }
  }

  List<dynamic> componentList = [];
  if (components != null) {
    for (RowBuilder element in components) {
      componentList.add(element.toJson());
    }
  }

  await ioc.use<HttpService>().post(url: "/webhooks/$id/$token", payload: {
    'username': username,
    'avatar_url': avatarUrl,
    'content': content,
    'embeds': embeds != null ? embedList : [],
    'components': components != null ? componentList : [],
    'tts': tts ?? false,
    'flags': suppressEmbed != null ? MessageFlag.suppressEmbeds.value : null
  });
}