Skip to content

Commit 500fb05

Browse files
committed
Add utm_source to outgoing links.
1 parent 06aba6e commit 500fb05

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

lib/messenger.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Messenger {
2020
embeds.forEach(embed => {
2121
this.msg.channel.sendEmbed(embed);
2222
});
23-
});
23+
}).catch(err => console.log(err));
2424
}
2525

2626
negotiateMatch(match) {

lib/middleware/utm.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const Url = require('urijs');
2+
3+
module.exports = (client, embed) => {
4+
console.log(embed);
5+
if (embed.url) {
6+
embed.url = Url(embed.url).query({ utm_source: 'discord' }).toString();
7+
}
8+
return embed;
9+
}

lib/response-types.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const Discord = require('discord.js');
33
const Url = require('urijs');
44

55
const manamoji = require('./middleware/manamoji');
6+
const utm = require('./middleware/utm');
7+
68

79
class TextResponse {
810
constructor(client, cardName) {
@@ -61,7 +63,7 @@ class TextResponse {
6163
}
6264
}
6365

64-
TextResponse.prototype.middleware = [ manamoji ];
66+
TextResponse.prototype.middleware = [ manamoji, utm ];
6567
TextResponse.prototype.url = 'https://api.scryfall.com/cards/named';
6668

6769

0 commit comments

Comments
 (0)