Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
feat: Show thumbnails of notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahsnider committed Dec 16, 2018
1 parent 08d1485 commit 139e606
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -72,5 +72,5 @@
"displayDate": true,
"displayTimestamp": true
},
"version": "3.9.3"
"version": "3.10.0"
}
23 changes: 18 additions & 5 deletions src/dice.js
Expand Up @@ -33,6 +33,7 @@ const { Batch } = require('reported');
const stripWebhookURL = require('./util/stripWebhookURL');
const packageData = require('../package');
const ms = require('ms');
const { oneLine } = require('common-tags');

// Use Sentry
if (config.sentryDSN) {
Expand Down Expand Up @@ -192,6 +193,9 @@ const announceGuildMemberJoin = (channel, member) => {
const embed = new MessageEmbed({
title: 'New Member',
timestamp: member.joinedAt,
thumbnail: {
url: 'https://dice.js.org/images/statuses/guildMember/join.png'
},
color: 0x4caf50,
author: {
name: `${member.user.tag} (${member.user.id})`,
Expand Down Expand Up @@ -221,8 +225,11 @@ const announceGuildMemberJoin = (channel, member) => {
const announceUserAccountBirthday = (channel, user) => channel.send({
embed: {
title: 'Discord Account Birthday',
// eslint-disable-next-line max-len
description: `It's the Discord account birthday of ${user.tag}. On this day in ${user.createdAt.getFullYear()} they created their Discord account.`,
thumbnail: {
url: 'https://dice.js.org/images/statuses/birthday/cake.png'
},
description: oneLine`It's the Discord account birthday of ${user.tag}.
On this day in ${user.createdAt.getFullYear()} they created their Discord account.`,
timestamp: new Date(),
color: 0x4caf50,
author: {
Expand All @@ -243,6 +250,9 @@ const announceGuildMemberLeave = (channel, member) => {
title: 'Member left',
timestamp: new Date(),
color: 0xf44336,
thumbnail: {
url: 'https://dice.js.org/images/statuses/guildMember/leave.png'
},
author: {
name: `${member.user.tag} (${member.user.id})`,
// eslint-disable-next-line camelcase
Expand Down Expand Up @@ -324,21 +334,24 @@ const announceVoiceChannelUpdate = (channel, oldVoiceState, newVoiceState) => {
.setTitle('Switched voice channels')
.setColor(0xff9800)
.addField('Old voice channel', Util.escapeMarkdown(oldVoiceState.channel.name))
.addField('New voice channel', Util.escapeMarkdown(newVoiceState.channel.name));
.addField('New voice channel', Util.escapeMarkdown(newVoiceState.channel.name))
.setThumbnail('https://dice.js.org/images/statuses/voiceChannel/transfer.png');
return channel.send(embed);
} else if (newVoiceState.channel && newVoiceState.channel !== oldVoiceState.channel) {
// Connected to a voice channel
embed
.setTitle('Connected to a voice channel')
.setColor(0x4caf50)
.addField('Voice channel', Util.escapeMarkdown(newVoiceState.channel.name));
.addField('Voice channel', Util.escapeMarkdown(newVoiceState.channel.name))
.setThumbnail('https://dice.js.org/images/statuses/voiceChannel/join.png');
return channel.send(embed);
} else if (oldVoiceState.channel && newVoiceState.channel !== oldVoiceState.channel) {
// Disconnected from a voice channel
embed
.setTitle('Disconnected from a voice channel')
.setColor(0xf44336)
.addField('Voice channel', Util.escapeMarkdown(oldVoiceState.channel.name));
.addField('Voice channel', Util.escapeMarkdown(oldVoiceState.channel.name))
.setThumbnail('https://dice.js.org/images/statuses/voiceChannel/leave.png');
return channel.send(embed);
}

Expand Down

0 comments on commit 139e606

Please sign in to comment.