Skip to content

Commit

Permalink
fix: show environment info in debug
Browse files Browse the repository at this point in the history
  • Loading branch information
vpctorr committed Jan 24, 2023
1 parent cc07378 commit d56be2f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
30 changes: 20 additions & 10 deletions packages/MakePDF/src/makepdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import { Client, WebhookClient, MessageAttachment, MessageEmbed } from 'discord.
import { get, request } from 'https'

import { convert } from './convert.js'

import info from '../package.json' assert { type: 'json' }
const version = (process.env.HEROKU_DEV && process.env.HEROKU_SLUG_DESCRIPTION) || info.version

const versionText = `MakePDF v${info.version}`
const environment = `${process.env.HEROKU_APP_NAME ?? 'local'} (${process.env.HEROKU_SLUG_DESCRIPTION ?? '…'})`

const client = new Client()
const hook = new WebhookClient(process.env.MAKEPDF_WEBHOOK_ID, process.env.MAKEPDF_WEBHOOK_TOKEN)

Expand All @@ -27,14 +31,20 @@ client.on('message', async (msg) => {
(mentions?.has(guild?.me, { ignoreEveryone: true }) && member?.hasPermission('ADMINISTRATOR'))
)
return msg.reply(
new MessageEmbed().setTitle('MakePDF – Debug').setColor('#ED4539').setDescription(`
**version :** MakePDF v${version}
**time :** ${Date.now()}
**lastRestart :** ${lastRestart}
**guildId :** ${msg.guild?.id}
**memberId :** ${author.id}
**channelId :** ${channel.id}
`)
new MessageEmbed()
.setTitle('MakePDF – Debug')
.setColor('#ED4539')
.setDescription(
`
**version :** ${versionText}
**environment :** ${environment}
**time :** ${Date.now()}
**lastRestart :** ${lastRestart}
**guildId :** ${msg.guild?.id}
**memberId :** ${author.id}
**channelId :** ${channel.id}
`
)
)

const filesArray = attachments.array()
Expand Down Expand Up @@ -93,7 +103,7 @@ const updateGuildCount = (server_count) => {
}

client.on('ready', () => {
log(`Bot (re)started, version ${version}`)
log(`${versionText} (re)started on ${environment}`)
updateGuildCount(client.guilds.cache.size)
})
client.on('guildCreate', () => updateGuildCount(client.guilds.cache.size))
Expand Down
10 changes: 6 additions & 4 deletions packages/VoiceNotify/src/voicenotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { request } from 'https'

import info from '../package.json' assert { type: 'json' }

const version = (process.env.HEROKU_DEV && process.env.HEROKU_SLUG_DESCRIPTION) || info.version
const versionText = `VoiceNotify v${info.version}`
const environment = `${process.env.HEROKU_APP_NAME ?? 'local'} (${process.env.HEROKU_SLUG_DESCRIPTION ?? '…'})`

const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_MESSAGES]
Expand Down Expand Up @@ -146,7 +147,8 @@ client.on('messageCreate', async (msg) => {
.setColor('#08C754')
.setDescription(
`
**version :** VoiceNotify v${version}
**version :** ${versionText}
**environment :** ${environment}
**time :** ${Date.now()}
**lastRestart :** ${lastRestart}
**guildId :** ${guild.id}
Expand All @@ -156,7 +158,7 @@ client.on('messageCreate', async (msg) => {
**lastThreshold :** ${thresholdTimes.get(member.voice?.channelId)}
**lastBroadcast :** ${broadcastTimes.get(member.voice?.channelId)}
**guildSettings :**\n\`\`\`${JSON.stringify(await manager.get(guild.id))}\`\`\`
`
`
)
]
})
Expand Down Expand Up @@ -198,7 +200,7 @@ const updateGuildCount = (server_count) => {
}

client.on('ready', () => {
log(`Bot (re)started, version ${version}`)
log(`${versionText} (re)started on ${environment}`)
updateGuildCount(client.guilds.cache.size)
})
client.on('guildCreate', () => updateGuildCount(client.guilds.cache.size))
Expand Down

0 comments on commit d56be2f

Please sign in to comment.