Add !list_dashboard_users
This commit is contained in:
parent
5f5113ee84
commit
1a5fe949af
2 changed files with 39 additions and 0 deletions
|
@ -15,6 +15,7 @@ import { AddDashboardUserCmd } from "./commands/AddDashboardUserCmd";
|
||||||
import { RemoveDashboardUserCmd } from "./commands/RemoveDashboardUserCmd";
|
import { RemoveDashboardUserCmd } from "./commands/RemoveDashboardUserCmd";
|
||||||
import { Configs } from "../../data/Configs";
|
import { Configs } from "../../data/Configs";
|
||||||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||||
|
import { ListDashboardUsersCmd } from "./commands/ListDashboardUsersCmd";
|
||||||
|
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
config: {
|
config: {
|
||||||
|
@ -37,6 +38,7 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()("bo
|
||||||
DisallowServerCmd,
|
DisallowServerCmd,
|
||||||
AddDashboardUserCmd,
|
AddDashboardUserCmd,
|
||||||
RemoveDashboardUserCmd,
|
RemoveDashboardUserCmd,
|
||||||
|
ListDashboardUsersCmd,
|
||||||
],
|
],
|
||||||
|
|
||||||
onLoad(pluginData) {
|
onLoad(pluginData) {
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { botControlCmd } from "../types";
|
||||||
|
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
|
import { ApiPermissions } from "@shared/apiPermissions";
|
||||||
|
import { resolveUser } from "../../../utils";
|
||||||
|
|
||||||
|
export const ListDashboardUsersCmd = botControlCmd({
|
||||||
|
trigger: ["list_dashboard_users"],
|
||||||
|
permission: null,
|
||||||
|
config: {
|
||||||
|
preFilters: [isOwnerPreFilter],
|
||||||
|
},
|
||||||
|
|
||||||
|
signature: {
|
||||||
|
guildId: ct.string(),
|
||||||
|
},
|
||||||
|
|
||||||
|
async run({ pluginData, message: msg, args }) {
|
||||||
|
const guild = await pluginData.state.allowedGuilds.find(args.guildId);
|
||||||
|
if (!guild) {
|
||||||
|
sendErrorMessage(pluginData, msg.channel, "Server is not using Zeppelin");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dashboardUsers = await pluginData.state.apiPermissionAssignments.getByGuildId(guild.id);
|
||||||
|
const users = await Promise.all(dashboardUsers.map(perm => resolveUser(pluginData.client, perm.target_id)));
|
||||||
|
const userNameList = users.map(
|
||||||
|
user => `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`,
|
||||||
|
);
|
||||||
|
|
||||||
|
sendSuccessMessage(
|
||||||
|
pluginData,
|
||||||
|
msg.channel,
|
||||||
|
`The following users have dashboard access for **${guild.name}**:\n\n${userNameList}`,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue