3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 22:21:51 +00:00

check if "channel" exists

This commit is contained in:
metal 2021-09-04 09:37:58 +00:00 committed by GitHub
parent 7f2731262d
commit 2821252a5a

View file

@ -65,32 +65,33 @@ export async function getInviteInfoEmbed(
`), `),
inline: true, inline: true,
}); });
if (invite.channel) {
const channelName =
invite.channel.type === ChannelTypeStrings.VOICE ? `🔉 ${invite.channel.name}` : `#${invite.channel.name}`;
const channelName = const channelCreatedAtTimestamp = snowflakeToTimestamp(invite.channel.id);
invite.channel.type === ChannelTypeStrings.VOICE ? `🔉 ${invite.channel.name}` : `#${invite.channel.name}`; const channelCreatedAt = moment.utc(channelCreatedAtTimestamp, "x");
const channelAge = humanizeDuration(Date.now() - channelCreatedAtTimestamp, {
largest: 2,
round: true,
});
const channelCreatedAtTimestamp = snowflakeToTimestamp(invite.channel.id); let channelInfo = trimLines(`
const channelCreatedAt = moment.utc(channelCreatedAtTimestamp, "x");
const channelAge = humanizeDuration(Date.now() - channelCreatedAtTimestamp, {
largest: 2,
round: true,
});
let channelInfo = trimLines(`
Name: **${channelName}** Name: **${channelName}**
ID: \`${invite.channel.id}\` ID: \`${invite.channel.id}\`
Created: **${channelAge} ago** Created: **${channelAge} ago**
`); `);
if (invite.channel.type !== ChannelTypeStrings.VOICE) { if (invite.channel.type !== ChannelTypeStrings.VOICE) {
channelInfo += `\nMention: <#${invite.channel.id}>`; channelInfo += `\nMention: <#${invite.channel.id}>`;
} }
embed.fields.push({ embed.fields.push({
name: preEmbedPadding + "Channel information", name: preEmbedPadding + "Channel information",
value: channelInfo, value: channelInfo,
inline: true, inline: true,
}); });
}
if (invite.inviter) { if (invite.inviter) {
embed.fields.push({ embed.fields.push({