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

Cleaned up code

This commit is contained in:
roflmaoqwerty 2020-01-11 02:05:54 +11:00
parent 12d8b19561
commit 4623475fb5

View file

@ -832,6 +832,21 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})** Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
`), `),
}); });
if (member) {
const joinedAt = moment(member.joinedAt);
const joinAge = humanizeDuration(moment().valueOf() - member.joinedAt, {
largest: 2,
round: true,
});
embed.fields[0].value += `\nJoined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})**`
} else {
embed.fields.push({
name: "!! USER IS NOT ON THE SERVER !!",
value: embedPadding,
});
}
msg.channel.createMessage({ embed });
return;
} }
else{ else{
embed.fields.push({ embed.fields.push({
@ -856,61 +871,52 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
}); });
const roles = member.roles.map(id => this.guild.roles.get(id)).filter(r => !!r); const roles = member.roles.map(id => this.guild.roles.get(id)).filter(r => !!r);
if(args.compact){ embed.fields.push({
embed.fields[0].value += `\n` + trimLines(`Joined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})**`); name: "Member information",
} value:
else{ trimLines(`
Joined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
${roles.length > 0 ? "Roles: " + roles.map(r => r.name).join(", ") : ""}
`) + embedPadding,
});
const voiceChannel = member.voiceState.channelID ? this.guild.channels.get(member.voiceState.channelID) : null;
if (voiceChannel || member.voiceState.mute || member.voiceState.deaf) {
embed.fields.push({ embed.fields.push({
name: "Member information", name: "Voice information",
value: value:
trimLines(` trimLines(`
Joined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})** ${voiceChannel ? `Current voice channel: **${voiceChannel ? voiceChannel.name : "None"}**` : ""}
${roles.length > 0 ? "Roles: " + roles.map(r => r.name).join(", ") : ""} ${member.voiceState.mute ? "Server voice muted: **Yes**" : ""}
`) + embedPadding, ${member.voiceState.deaf ? "Server voice deafened: **Yes**" : ""}
`) + embedPadding,
}); });
} }
if(!args.compact){
const voiceChannel = member.voiceState.channelID ? this.guild.channels.get(member.voiceState.channelID) : null;
if (voiceChannel || member.voiceState.mute || member.voiceState.deaf) {
embed.fields.push({
name: "Voice information",
value:
trimLines(`
${voiceChannel ? `Current voice channel: **${voiceChannel ? voiceChannel.name : "None"}**` : ""}
${member.voiceState.mute ? "Server voice muted: **Yes**" : ""}
${member.voiceState.deaf ? "Server voice deafened: **Yes**" : ""}
`) + embedPadding,
});
}
}
} else { } else {
embed.fields.push({ embed.fields.push({
name: "!! USER IS NOT ON THE SERVER !!", name: "!! USER IS NOT ON THE SERVER !!",
value: embedPadding, value: embedPadding,
}); });
} }
if(!args.compact){ const cases = (await this.cases.getByUserId(user.id)).filter(c => !c.is_hidden);
const cases = (await this.cases.getByUserId(user.id)).filter(c => !c.is_hidden);
if (cases.length > 0) { if (cases.length > 0) {
cases.sort((a, b) => { cases.sort((a, b) => {
return a.created_at < b.created_at ? 1 : -1; return a.created_at < b.created_at ? 1 : -1;
}); });
const caseSummary = cases.slice(0, 3).map(c => { const caseSummary = cases.slice(0, 3).map(c => {
return `${CaseTypes[c.type]} (#${c.case_number})`; return `${CaseTypes[c.type]} (#${c.case_number})`;
}); });
const summaryText = cases.length > 3 ? "Last 3 cases" : "Summary"; const summaryText = cases.length > 3 ? "Last 3 cases" : "Summary";
embed.fields.push({ embed.fields.push({
name: "Cases", name: "Cases",
value: trimLines(` value: trimLines(`
Total cases: **${cases.length}** Total cases: **${cases.length}**
${summaryText}: ${caseSummary.join(", ")} ${summaryText}: ${caseSummary.join(", ")}
`), `),
}); });
}
} }
msg.channel.createMessage({ embed }); msg.channel.createMessage({ embed });
} }