This commit is contained in:
bignutty 2024-08-07 20:47:40 +02:00
commit cb1fcf9935

View file

@ -7,6 +7,8 @@ const { editOrReply } = require('#utils/message');
// TODO: Turn this into a general purpose permissions constant
const { Permissions } = require("detritus-client/lib/constants");
const superagent = require("superagent");
// TODO: Move this into utils
function format(seconds){
function pad(s){
@ -61,15 +63,27 @@ module.exports = {
formatted.usage += cstats.usage
}
let applicationMetadata;
try{
applicationMetadata = await superagent.get(`https://canary.discord.com/api/v9/applications/${context.client.user.id}`)
.set({
"Authorization": "Bot " + context.client.token
})
}catch(e){}
const display = [
`${iconPill("home", "Servers ")} ${highlight(` ${formatted.guilds} `)}`,
`${iconPill("robot", "Shard ")} ${highlight(` ${context.shardId + 1}/${context.manager.cluster.shardCount} `)}`,
`${iconPill("latency", "Memory Usage")} ${highlight(` ${Math.round(formatted.usage / 1024 / 1024)}MB `)}`,
`${iconPill("clock", "Uptime ")} ${highlight(` ${format(process.uptime())} `)}`,
``,
`${iconLinkPill('gitlab', OPEN_SOURCE_REPOSITORY_URL, 'Source Code')} ${iconLinkPill('link', context.application.oauth2UrlFormat({ scope: 'bot applications.commands', permissions: 412317248576 }), `Invite ${context.client.user.username}`).replace("ptb.discordapp.com","discord.com")}`
`${iconPill("home", "Servers ")} ${highlight(` ${formatted.guilds} `)}`
]
if(applicationMetadata.body?.approximate_user_install_count)
display.push(`${iconPill("user", "Installations")} ${highlight(` ${applicationMetadata.body.approximate_user_install_count} `)}`)
display.push(`${iconPill("robot", "Shard ")} ${highlight(` ${context.shardId + 1}/${context.manager.cluster.shardCount} `)}`)
display.push(`${iconPill("latency", "Memory Usage ")} ${highlight(` ${Math.round(formatted.usage / 1024 / 1024)}MB `)}`)
display.push(`${iconPill("clock", "Uptime ")} ${highlight(` ${format(process.uptime())} `)}`)
display.push(``)
display.push(`${iconLinkPill('gitlab', OPEN_SOURCE_REPOSITORY_URL, 'Source Code')} ${iconLinkPill('link', context.application.oauth2UrlFormat({ scope: 'bot applications.commands', permissions: 412317248576 }), `Invite ${context.client.user.username}`).replace("ptb.discordapp.com","discord.com")}`)
return editOrReply(context, createEmbed("default", context, {
description: display.join('\n')
}))