pissbot-9000/commands/message/info/guild.js
2023-04-16 01:34:37 +02:00

90 lines
No EOL
3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { createEmbed } = require("../../../labscore/utils/embed");
const { guildFeaturesField } = require("../../../labscore/utils/fields");
const { icon, highlight, timestamp, codeblock } = require("../../../labscore/utils/markdown");
const { editOrReply } = require("../../../labscore/utils/message");
module.exports = {
name: 'server',
label: 'user',
aliases: ['guild', 'guildinfo'],
metadata: {
description: 'Displays information about the server.',
description_short: 'Information about the server',
examples: ['guild'],
category: 'info',
usage: 'server'
},
run: async (context) => {
try{
const emojis = context.message.guild.emojis
const animojis = emojis.filter(emoji => emoji.animated).length
const channels = context.message.guild.channels
const categoryChannels = channels.filter((channel) => channel.isGuildCategory).length;
const newsChannels = channels.filter((channel) => channel.isGuildNews).length;
const textChannels = channels.filter((channel) => channel.isGuildText).length;
const voiceChannels = channels.filter((channel) => channel.isGuildVoice).length;
const stageChannels = channels.filter((channel) => channel.isGuildStageVoice).length;
const g = context.guild
// Guild Card
let guildCard = createEmbed("default", context, {
description: `${icon("house")} **${g.name}** ${highlight(`(${g.id})`)}\n\n${icon("calendar")} **Created at: **${timestamp(g.createdAt, "f")}`,
thumbnail: {
url: g.iconUrl + `?size=4096`
},
fields: []
})
if(g.owner) guildCard.description += `\n\n<:lc_guild_owner:674652779406426122> **Server Owner: **<@${g.owner.id}>`
// Channel Container
guildCard.fields.push({
name: `${icon("channel")} Channels`,
value: codeblock("py", [
`Text Channels ${textChannels}`,
`Voice Channels ${voiceChannels}`,
`Stage Channels ${stageChannels}`,
`Announcement Channels ${newsChannels}`,
`Categories ${categoryChannels}`,
``,
`Total ${channels.length}`,
]),
inline: true
})
// Emoji Container
guildCard.fields.push({
name: `${icon("emoji")} Emoji`,
value: codeblock("py", [
`Regular ${emojis.length - animojis}`,
`Animated ${animojis}`,
``,
`Total ${emojis.length}`,
]),
inline: true
})
// Guild Features
if(g.features.length >= 1){
// Create an empty field so everything properly aligns on desktop
guildCard.fields.push({
name: ``,
value: ``,
inline: true
})
let featureCards = guildFeaturesField(g)
featureCards[0].name = `${icon("activity")} Guild Features`
guildCard.fields = guildCard.fields.concat(featureCards)
}
return editOrReply(context, guildCard)
}catch(e){
console.log(e)
}
},
};