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

Send version messages concurrently #2

Open
wants to merge 2 commits 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
14 changes: 6 additions & 8 deletions minecraft-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,17 @@ async function poll () {
}

const fancySize = size => {
const mbs = size / (1024 * 1204)
const mbs = size / (1024 * 1024)
return mbs.toFixed(1) + 'MB'
}

async function update (version) {
const embed = await getUpdateEmbed(version)
if (config.webhook) await request.post(config.webhook, {json: {embeds: [embed]}})
if (config.channels) {
for (const id of config.channels) {
const channel = await client.channels.fetch(id)
await channel.send({embeds: [embed]})
}
}

await Promise.all([
config.webhook && request.post(config.webhook, {json: {embeds: [embed]}}),
...(config.channels?.map(id => client.channels.fetch(id).then(channel => channel.send({embeds: [embed]}))) ?? [])
])
}

async function getUpdateEmbed (version) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"repository": "https://github.com/SciCraft/SciCraftBot",
"license": "MIT",
"dependencies": {
"@discordjs/builders": "^0.6.0",
"@discordjs/rest": "^0.1.0-canary.0",
"discord-api-types": "^0.23.1",
"discord.js": "^13.1.0",
"@discordjs/builders": "^0.11.0",
"@discordjs/rest": "^0.2.0-canary.0",
"discord-api-types": "^0.26.1",
"discord.js": "^13.6.0",
"html-entities": "^2.3.2",
"jira-client": "^6.11.0",
"node-fetch": "^2.6.1",
Expand Down
Loading