Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Discord Webhook to use embeds instead of raw text to avoid 2000 character limit #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Thumbs.db
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this file? Seems like it's not needed

20 changes: 11 additions & 9 deletions src/Encounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,16 @@ class Encounter extends Component {
totalDps: this.props.ENCDPS,
maxhit: maxhitName
}
const encounterRow = `\`${'='.repeat(
85
)}\`\n\`${encData.title} | ${encData.zone} | ${encData.duration} | ${encData.totalDps} | ${encData.maxhit}\`\n\`${'-'.repeat(
85
)}\``

const data = this.props.discordData

// [JOB] CHARACTER | 💪 DPS (DPS%) | 💊 HEAL (HEAL%) | 💀 DEATH | 💣 CRIT% | 🎯 DHIT% |`
const combatantRow = data.map(combatant => {
return `\n**[${combatant.job}] ${combatant.characterName}** \`| DPS: ${combatant.dps} (${combatant.damage}%) | HPS: ${combatant.hps} (${combatant.healed}) | DIE: ${combatant.deaths} | CRIT: ${combatant.crit} | DHIT: ${combatant.dhit} |\`\n\`${'-'.repeat(
85
)}\``
return {
name: `[${combatant.job}] ${combatant.characterName}:`,
value: `**DPS:** ${combatant.dps} (${combatant.damage}%)\n**HPS:** ${combatant.hps} (${combatant.healed})\n**DIE:** ${combatant.deaths}\n**CRIT:** ${combatant.crit}\n**DHIT:** ${combatant.dhit}`,
inline: true
}
})

fetch(this.props.config.discord, {
Expand All @@ -51,7 +48,12 @@ class Encounter extends Component {
username: 'H O R I Z O V E R L A Y',
avatar_url:
'https://68.media.tumblr.com/2d83ce19282a68c3e2365be87254ae6a/tumblr_oh9wzyYbdb1u9t5z9o1_500.gif',
content: `${encounterRow}${combatantRow.join('', ',')}`
embeds: [{
title: `__${encData.title} | ${encData.zone}__`,
description: `**Duration:** ${encData.duration}\n**Total DPS:** ${encData.totalDps}\n**Max Hit:** ${encData.maxhit}`,
color: 0x22009d,
fields: combatantRow
}]
})
})
}
Expand Down