Show more information in !list_dashboard_perms
This commit is contained in:
parent
6038996f10
commit
853394ecad
1 changed files with 16 additions and 6 deletions
|
@ -45,26 +45,36 @@ export const ListDashboardPermsCmd = botControlCmd({
|
||||||
|
|
||||||
// If we have user, always display which guilds they have permissions in (or only specified guild permissions)
|
// If we have user, always display which guilds they have permissions in (or only specified guild permissions)
|
||||||
if (args.user) {
|
if (args.user) {
|
||||||
|
const userInfo = `**${args.user.username}#${args.user.discriminator}** (\`${args.user.id}\`)`;
|
||||||
|
|
||||||
for (const assignment of existingUserAssignment!) {
|
for (const assignment of existingUserAssignment!) {
|
||||||
if (guild != null && assignment.guild_id !== args.guildId) continue;
|
if (guild != null && assignment.guild_id !== args.guildId) continue;
|
||||||
finalMessage += `The user has the following permissions on server \`${
|
const assignmentGuild = await pluginData.state.allowedGuilds.find(assignment.guild_id);
|
||||||
assignment.guild_id
|
const guildName = assignmentGuild?.name ?? "Unknown";
|
||||||
}\`:\n${assignment.permissions.join("\n")}\n\n`;
|
const guildInfo = `**${guildName}** (\`${assignment.guild_id}\`)`;
|
||||||
|
finalMessage += `The user ${userInfo} has the following permissions on server ${guildInfo}:`;
|
||||||
|
finalMessage += `\n${assignment.permissions.join("\n")}\n\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalMessage === "") {
|
if (finalMessage === "") {
|
||||||
sendErrorMessage(pluginData, msg.channel, "The user has no assigned permissions on the specified server.");
|
sendErrorMessage(
|
||||||
|
pluginData,
|
||||||
|
msg.channel,
|
||||||
|
`The user ${userInfo} has no assigned permissions on the specified server.`,
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Else display all users that have permissions on the specified guild
|
// Else display all users that have permissions on the specified guild
|
||||||
} else if (guild) {
|
} else if (guild) {
|
||||||
|
const guildInfo = `**${guild.name}** (\`${guild.id}\`)`;
|
||||||
|
|
||||||
const existingGuildAssignment = await pluginData.state.apiPermissionAssignments.getByGuildId(guild.id);
|
const existingGuildAssignment = await pluginData.state.apiPermissionAssignments.getByGuildId(guild.id);
|
||||||
if (existingGuildAssignment.length === 0) {
|
if (existingGuildAssignment.length === 0) {
|
||||||
sendErrorMessage(pluginData, msg.channel, "The server has no assigned permissions.");
|
sendErrorMessage(pluginData, msg.channel, `The server ${guildInfo} has no assigned permissions.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
finalMessage += `The server \`${guild.id}\` has the following assigned permissions:\n`; // Double \n for consistency with AddDashboardUserCmd
|
finalMessage += `The server ${guildInfo} has the following assigned permissions:\n`; // Double \n for consistency with AddDashboardUserCmd
|
||||||
for (const assignment of existingGuildAssignment) {
|
for (const assignment of existingGuildAssignment) {
|
||||||
const user = await resolveUser(pluginData.client, assignment.target_id);
|
const user = await resolveUser(pluginData.client, assignment.target_id);
|
||||||
finalMessage += `\n**${user.username}#${user.discriminator}**, \`${
|
finalMessage += `\n**${user.username}#${user.discriminator}**, \`${
|
||||||
|
|
Loading…
Add table
Reference in a new issue