message: Added initial support for webhooks. Need next version of discord.js before file attachments will work through webhooks.
diff: @@ -159,7 +159,11 @@ export class DiscordBot {
  const profile = result.botUser ? await mxClient.getProfileInfo(event.sender) : null;
  const embed = this.MatrixEventToEmbed(event, profile, chan);
  let opts : Discord.MessageOptions = {};
  - if (["m.image", "m.audio", "m.video", "m.file"].indexOf(event.content.msgtype) !== -1) {
  + let hookOpts : Discord.WebhookMessageOptions = {
  + username: event.sender,
  + };
  + const hasAttachment = ["m.image", "m.audio", "m.video", "m.file"].indexOf(event.content.msgtype) !== -1;
  + if (hasAttachment) {
  const attachment = await Util.DownloadFile(mxClient.mxcUrlToHttp(event.content.url));
  const name = this.GetFilenameForMediaEvent(event.content);
  opts.file = {
  @@ -168,12 +172,21 @@ export class DiscordBot {
  };
  }
  let msg = null;
  + const webhooks = await chan.fetchWebhooks();
  + const hook : Discord.Webhook = webhooks.filterArray((h) => h.name === "_matrix").pop();
  try {
  - if (botUser) {
  + if (!botUser) {
  + msg = await chan.send(embed.description, opts);
  + } else if (hook && !hasAttachment) { //Remove !hasAttachment when https://github.com/hydrabolt/discord.js/pull/1449 is fixed
  + if (hasAttachment) {
  + hookOpts.file = opts.file;
  + msg = await hook.send(embed.description, hookOpts);
  + } else {
  + msg = await hook.send(embed.description, hookOpts);
  + }
  + } else {
  opts.embed = embed;
  msg = await chan.send("", opts);
  - } else {
  - msg = await chan.send(embed.description, opts);
  }
  } catch (err) {
  log.error("DiscordBot", "Couldn't send message. ", err);
  