Added compact switch to !info
This commit is contained in:
parent
c255019d43
commit
12d8b19561
1 changed files with 69 additions and 44 deletions
|
@ -792,9 +792,16 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
basicUsage: "!info 106391128718245888",
|
basicUsage: "!info 106391128718245888",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "compact",
|
||||||
|
shortcut: "c",
|
||||||
|
isSwitch: true,
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
@d.permission("can_info")
|
@d.permission("can_info")
|
||||||
async infoCmd(msg: Message, args: { user?: User | UnknownUser }) {
|
async infoCmd(msg: Message, args: { user?: User | UnknownUser, compact?: boolean }) {
|
||||||
const user = args.user || msg.author;
|
const user = args.user || msg.author;
|
||||||
|
|
||||||
let member;
|
let member;
|
||||||
|
@ -816,15 +823,27 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
embed.title = `${user.username}#${user.discriminator}`;
|
embed.title = `${user.username}#${user.discriminator}`;
|
||||||
embed.thumbnail = { url: user.avatarURL };
|
embed.thumbnail = { url: user.avatarURL };
|
||||||
|
|
||||||
embed.fields.push({
|
if(args.compact){
|
||||||
name: "User information",
|
embed.fields.push({
|
||||||
value:
|
name: "User information",
|
||||||
trimLines(`
|
value:
|
||||||
ID: **${user.id}**
|
trimLines(`
|
||||||
Profile: <@!${user.id}>
|
Profile: <@!${user.id}>
|
||||||
Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
|
Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
|
||||||
`) + embedPadding,
|
`),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
embed.fields.push({
|
||||||
|
name: "User information",
|
||||||
|
value:
|
||||||
|
trimLines(`
|
||||||
|
ID: **${user.id}**
|
||||||
|
Profile: <@!${user.id}>
|
||||||
|
Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
|
||||||
|
`) + embedPadding,
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
embed.title = `Unknown user`;
|
embed.title = `Unknown user`;
|
||||||
}
|
}
|
||||||
|
@ -837,56 +856,62 @@ 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);
|
||||||
|
|
||||||
embed.fields.push({
|
if(args.compact){
|
||||||
name: "Member information",
|
embed.fields[0].value += `\n` + trimLines(`Joined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})**`);
|
||||||
value:
|
}
|
||||||
trimLines(`
|
else{
|
||||||
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: "Voice information",
|
name: "Member information",
|
||||||
value:
|
value:
|
||||||
trimLines(`
|
trimLines(`
|
||||||
${voiceChannel ? `Current voice channel: **${voiceChannel ? voiceChannel.name : "None"}**` : ""}
|
Joined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
|
||||||
${member.voiceState.mute ? "Server voice muted: **Yes**" : ""}
|
${roles.length > 0 ? "Roles: " + roles.map(r => r.name).join(", ") : ""}
|
||||||
${member.voiceState.deaf ? "Server voice deafened: **Yes**" : ""}
|
`) + embedPadding,
|
||||||
`) + 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) {
|
||||||
|
cases.sort((a, b) => {
|
||||||
|
return a.created_at < b.created_at ? 1 : -1;
|
||||||
|
});
|
||||||
|
|
||||||
if (cases.length > 0) {
|
const caseSummary = cases.slice(0, 3).map(c => {
|
||||||
cases.sort((a, b) => {
|
return `${CaseTypes[c.type]} (#${c.case_number})`;
|
||||||
return a.created_at < b.created_at ? 1 : -1;
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const caseSummary = cases.slice(0, 3).map(c => {
|
const summaryText = cases.length > 3 ? "Last 3 cases" : "Summary";
|
||||||
return `${CaseTypes[c.type]} (#${c.case_number})`;
|
|
||||||
});
|
|
||||||
|
|
||||||
const summaryText = cases.length > 3 ? "Last 3 cases" : "Summary";
|
embed.fields.push({
|
||||||
|
name: "Cases",
|
||||||
embed.fields.push({
|
value: trimLines(`
|
||||||
name: "Cases",
|
Total cases: **${cases.length}**
|
||||||
value: trimLines(`
|
${summaryText}: ${caseSummary.join(", ")}
|
||||||
Total cases: **${cases.length}**
|
`),
|
||||||
${summaryText}: ${caseSummary.join(", ")}
|
});
|
||||||
`),
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.channel.createMessage({ embed });
|
msg.channel.createMessage({ embed });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue