mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -04:00
invite info
This commit is contained in:
parent
8df2949a27
commit
eb77a9896c
2 changed files with 70 additions and 4 deletions
63
commands/message/info/invite.js
Normal file
63
commands/message/info/invite.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
const { GUILD_FEATURES } = require("../../../labscore/constants");
|
||||||
|
const { createEmbed } = require("../../../labscore/utils/embed");
|
||||||
|
const { icon, highlight, timestamp, codeblock } = require("../../../labscore/utils/markdown");
|
||||||
|
const { editOrReply } = require("../../../labscore/utils/message");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'invite',
|
||||||
|
label: 'invite',
|
||||||
|
aliases: ['inviteinfo'],
|
||||||
|
metadata: {
|
||||||
|
description: 'invite info',
|
||||||
|
examples: ['invite discord-townhall'],
|
||||||
|
category: 'info',
|
||||||
|
usage: 'invite <invite code>'
|
||||||
|
},
|
||||||
|
run: async (context, args) => {
|
||||||
|
context.triggerTyping();
|
||||||
|
try{
|
||||||
|
const inviteCode = args.invite.match(/(?:(?:https|http):\/\/)?(?:(?:discord.gg|(?:discord|discordapp)\.com\/invite)\/)?([A-z0-z-]{2,32})/)
|
||||||
|
const invite = await context.client.rest.fetchInvite(inviteCode[1], {withCounts: true})
|
||||||
|
|
||||||
|
const g = invite.guild
|
||||||
|
// Guild Card
|
||||||
|
let inviteCard = createEmbed("default", context, {
|
||||||
|
description: `${icon("link")} **https://discord.gg/${inviteCode[1]}**\n\n${icon("house")} **${g.name}** ${highlight(`(${g.id})`)}\n${icon("calendar")} **Created at: **${timestamp(g.createdAt, "f")}\n\n${icon("people")}${highlight(invite.approximateMemberCount.toLocaleString())} ${icon("online")}${highlight(invite.approximatePresenceCount.toLocaleString())} ${icon("offline")}${highlight((invite.approximateMemberCount - invite.approximatePresenceCount).toLocaleString())}`,
|
||||||
|
thumbnail: {
|
||||||
|
url: g.iconUrl + `?size=4096`
|
||||||
|
},
|
||||||
|
fields: []
|
||||||
|
})
|
||||||
|
|
||||||
|
// Guild Features
|
||||||
|
if(g.features.length >= 1){
|
||||||
|
guildFeatures = g.features.sort((a, b) => a.normalize().localeCompare(b.normalize()));
|
||||||
|
|
||||||
|
let featureCards = []
|
||||||
|
while(guildFeatures.length){
|
||||||
|
ff = guildFeatures.splice(0, 10)
|
||||||
|
let f = [];
|
||||||
|
for(const feat of ff){
|
||||||
|
if(GUILD_FEATURES[feat]){
|
||||||
|
f.push(GUILD_FEATURES[feat])
|
||||||
|
} else {
|
||||||
|
f.push(`<:UNKNOWN:878298902971965520> ${feat}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
featureCards.push({
|
||||||
|
name: ``,
|
||||||
|
value: f.join('\n'),
|
||||||
|
inline: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
featureCards[0].name = `${icon("activity")} Guild Features`
|
||||||
|
inviteCard.fields = inviteCard.fields.concat(featureCards)
|
||||||
|
}
|
||||||
|
|
||||||
|
return editOrReply(context, { embeds: [inviteCard] })
|
||||||
|
}catch(e){
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -69,7 +69,10 @@ module.exports.ICONS = Object.freeze({
|
||||||
"reddit_gold": "<:rdt_gold:993630360527196251>",
|
"reddit_gold": "<:rdt_gold:993630360527196251>",
|
||||||
"reddit_silver": "<:rdt_silver:993630364327231628>",
|
"reddit_silver": "<:rdt_silver:993630364327231628>",
|
||||||
"reddit_wholesome": "<:rdt_wholesome:993630485379031061>",
|
"reddit_wholesome": "<:rdt_wholesome:993630485379031061>",
|
||||||
"reddit_helpful": "<:rdt_helpful:993630362372677774>"
|
"reddit_helpful": "<:rdt_helpful:993630362372677774>",
|
||||||
|
"online": "<:ico_online:994362211772399736>",
|
||||||
|
"offline": "<:ico_offline:994362210061123598>",
|
||||||
|
"link": "<:ico_link:994364481792647229>"
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports.GUILD_FEATURES = Object.freeze({
|
module.exports.GUILD_FEATURES = Object.freeze({
|
||||||
|
@ -100,9 +103,9 @@ module.exports.GUILD_FEATURES = Object.freeze({
|
||||||
"SEVEN_DAY_THREAD_ARCHIVE": "<:THREAD_ARCHIVING:878297227729174568> 7 Day Thread Archiving",
|
"SEVEN_DAY_THREAD_ARCHIVE": "<:THREAD_ARCHIVING:878297227729174568> 7 Day Thread Archiving",
|
||||||
"THREE_DAY_THREAD_ARCHIVE": "<:THREAD_ARCHIVING:878297227729174568> 3 Day Thread Archiving",
|
"THREE_DAY_THREAD_ARCHIVE": "<:THREAD_ARCHIVING:878297227729174568> 3 Day Thread Archiving",
|
||||||
"PRIVATE_THREADS": "<:PRIVATE_THREADS:878297227729174569> Private Threads",
|
"PRIVATE_THREADS": "<:PRIVATE_THREADS:878297227729174569> Private Threads",
|
||||||
"THREADS_ENABLED_TESTING": "<:lc_thread:749595231376375829> Threads Testing Enabled",
|
"THREADS_ENABLED_TESTING": "<:thread:994365140617154692> Threads Testing Enabled",
|
||||||
"THREADS_ENABLED": "<:lc_thread:749595231376375829> Threads Enabled",
|
"THREADS_ENABLED": "<:thread:994365140617154692> Threads Enabled",
|
||||||
"NEW_THREAD_PERMISSIONS": "<:lc_thread:881925657150504970> New Thread Permissions Enabled",
|
"NEW_THREAD_PERMISSIONS": "<:thread:994365140617154692> New Thread Permissions Enabled",
|
||||||
"ROLE_ICONS": "<:ROLE_ICONS:878297142022795275> Role Icons",
|
"ROLE_ICONS": "<:ROLE_ICONS:878297142022795275> Role Icons",
|
||||||
"ROLE_SUBSCRIPTIONS_ENABLED": "<:ROLE_SUBSCRIPTIONS_ENABLED:888440487101485116> Role Subscriptions Enabled",
|
"ROLE_SUBSCRIPTIONS_ENABLED": "<:ROLE_SUBSCRIPTIONS_ENABLED:888440487101485116> Role Subscriptions Enabled",
|
||||||
"ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE": "<:ROLE_SUBSCRIPTIONS_ENABLED:888440487101485116> Role Subscriptions Available for Purchase",
|
"ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE": "<:ROLE_SUBSCRIPTIONS_ENABLED:888440487101485116> Role Subscriptions Available for Purchase",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue