Skip to content
Extraits de code Groupes Projets
Valider a956b187 rédigé par Will Hunt's avatar Will Hunt
Parcourir les fichiers

Fix up webhook author bits

parent a462e20f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -159,10 +159,6 @@ export class DiscordBot {
const profile = result.botUser ? await mxClient.getProfileInfo(event.sender) : null;
const embed = this.MatrixEventToEmbed(event, profile, chan);
let opts : Discord.MessageOptions = {};
let hookOpts : Discord.WebhookMessageOptions = {
username: profile.displayname,
avatarURL: profile.icon_url,
};
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));
......@@ -173,12 +169,19 @@ export class DiscordBot {
};
}
let msg = null;
let hook : Discord.Webhook ;
if(botUser) {
const webhooks = await chan.fetchWebhooks();
const hook : Discord.Webhook = webhooks.filterArray((h) => h.name === "_matrix").pop();
hook = webhooks.filterArray((h) => h.name === "_matrix").pop();
}
try {
if (!botUser) {
msg = await chan.send(embed.description, opts);
} else if (hook && !hasAttachment) { //Remove !hasAttachment and uncomment below when https://github.com/hydrabolt/discord.js/pull/1449 is fixed
const hookOpts : Discord.WebhookMessageOptions = {
username: embed.author.name,
avatarURL: embed.author.icon_url,
};
//if (hasAttachment) {
// hookOpts.file = opts.file;
// msg = await hook.send(embed.description, hookOpts);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter