mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41: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_performance: false,
|
||||
can_add_server_from_invite: false,
|
||||
can_list_dashboard_perms: false,
|
||||
update_cmd: null,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -7,11 +7,8 @@ import { resolveUser } from "../../../utils";
|
|||
import { botControlCmd } from "../types";
|
||||
|
||||
export const ListDashboardPermsCmd = botControlCmd({
|
||||
trigger: ["list_dashboard_permissions", "list_dashboard_perms", "list_dash_permissionss", "list_dash_perms"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
},
|
||||
trigger: ["list_dashboard_permissions", "list_dashboard_perms", "list_dash_permissions", "list_dash_perms"],
|
||||
permission: "can_list_dashboard_perms",
|
||||
|
||||
signature: {
|
||||
guildId: ct.string({ option: true, shortcut: "g" }),
|
||||
|
|
|
@ -6,10 +6,7 @@ import { botControlCmd } from "../types";
|
|||
|
||||
export const ListDashboardUsersCmd = botControlCmd({
|
||||
trigger: ["list_dashboard_users"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
},
|
||||
permission: "can_list_dashboard_perms",
|
||||
|
||||
signature: {
|
||||
guildId: ct.string(),
|
||||
|
@ -23,13 +20,21 @@ export const ListDashboardUsersCmd = botControlCmd({
|
|||
}
|
||||
|
||||
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.tag}**, \`${user.id}\`)`);
|
||||
const users = await Promise.all(
|
||||
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(
|
||||
pluginData,
|
||||
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_performance: t.boolean,
|
||||
can_add_server_from_invite: t.boolean,
|
||||
can_list_dashboard_perms: t.boolean,
|
||||
update_cmd: tNullable(t.string),
|
||||
});
|
||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
|
Loading…
Add table
Reference in a new issue