mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Use permissions for dashboard perm listing commands
This commit is contained in:
parent
57421a8439
commit
375837c31f
4 changed files with 16 additions and 12 deletions
|
@ -27,6 +27,7 @@ const defaultOptions = {
|
||||||
can_eligible: false,
|
can_eligible: false,
|
||||||
can_performance: false,
|
can_performance: false,
|
||||||
can_add_server_from_invite: false,
|
can_add_server_from_invite: false,
|
||||||
|
can_list_dashboard_perms: false,
|
||||||
update_cmd: null,
|
update_cmd: null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,11 +7,8 @@ import { resolveUser } from "../../../utils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
export const ListDashboardPermsCmd = botControlCmd({
|
export const ListDashboardPermsCmd = botControlCmd({
|
||||||
trigger: ["list_dashboard_permissions", "list_dashboard_perms", "list_dash_permissionss", "list_dash_perms"],
|
trigger: ["list_dashboard_permissions", "list_dashboard_perms", "list_dash_permissions", "list_dash_perms"],
|
||||||
permission: null,
|
permission: "can_list_dashboard_perms",
|
||||||
config: {
|
|
||||||
preFilters: [isOwnerPreFilter],
|
|
||||||
},
|
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
guildId: ct.string({ option: true, shortcut: "g" }),
|
guildId: ct.string({ option: true, shortcut: "g" }),
|
||||||
|
|
|
@ -6,10 +6,7 @@ import { botControlCmd } from "../types";
|
||||||
|
|
||||||
export const ListDashboardUsersCmd = botControlCmd({
|
export const ListDashboardUsersCmd = botControlCmd({
|
||||||
trigger: ["list_dashboard_users"],
|
trigger: ["list_dashboard_users"],
|
||||||
permission: null,
|
permission: "can_list_dashboard_perms",
|
||||||
config: {
|
|
||||||
preFilters: [isOwnerPreFilter],
|
|
||||||
},
|
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
guildId: ct.string(),
|
guildId: ct.string(),
|
||||||
|
@ -23,13 +20,21 @@ export const ListDashboardUsersCmd = botControlCmd({
|
||||||
}
|
}
|
||||||
|
|
||||||
const dashboardUsers = await pluginData.state.apiPermissionAssignments.getByGuildId(guild.id);
|
const dashboardUsers = await pluginData.state.apiPermissionAssignments.getByGuildId(guild.id);
|
||||||
const users = await Promise.all(dashboardUsers.map(perm => resolveUser(pluginData.client, perm.target_id)));
|
const users = await Promise.all(
|
||||||
const userNameList = users.map(user => `<@!${user.id}> (**${user.tag}**, \`${user.id}\`)`);
|
dashboardUsers.map(async perm => ({
|
||||||
|
user: await resolveUser(pluginData.client, perm.target_id),
|
||||||
|
permission: perm,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
const userNameList = users.map(
|
||||||
|
({ user, permission }) =>
|
||||||
|
`<@!${user.id}> (**${user.tag}**, \`${user.id}\`): ${permission.permissions.join(", ")}`,
|
||||||
|
);
|
||||||
|
|
||||||
sendSuccessMessage(
|
sendSuccessMessage(
|
||||||
pluginData,
|
pluginData,
|
||||||
msg.channel as TextChannel,
|
msg.channel as TextChannel,
|
||||||
`The following users have dashboard access for **${guild.name}**:\n\n${userNameList}`,
|
`The following users have dashboard access for **${guild.name}**:\n\n${userNameList.join("\n")}`,
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,6 +11,7 @@ export const ConfigSchema = t.type({
|
||||||
can_eligible: t.boolean,
|
can_eligible: t.boolean,
|
||||||
can_performance: t.boolean,
|
can_performance: t.boolean,
|
||||||
can_add_server_from_invite: t.boolean,
|
can_add_server_from_invite: t.boolean,
|
||||||
|
can_list_dashboard_perms: t.boolean,
|
||||||
update_cmd: tNullable(t.string),
|
update_cmd: tNullable(t.string),
|
||||||
});
|
});
|
||||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||||
|
|
Loading…
Add table
Reference in a new issue