mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-19 07:20:00 +00:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
![]() |
import { botControlCmd } from "../types";
|
||
|
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||
|
import { ApiPermissions } from "@shared/apiPermissions";
|
||
|
|
||
|
export const RemoveDashboardUserCmd = botControlCmd({
|
||
|
trigger: ["remove_dashboard_user"],
|
||
|
permission: null,
|
||
|
config: {
|
||
|
preFilters: [isOwnerPreFilter],
|
||
|
},
|
||
|
|
||
|
signature: {
|
||
|
guildId: ct.string(),
|
||
|
users: ct.user({ rest: true }),
|
||
|
},
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
for (const user of args.users) {
|
||
|
const existingAssignment = await pluginData.state.apiPermissionAssignments.getByGuildAndUserId(
|
||
|
args.guildId,
|
||
|
user.id,
|
||
|
);
|
||
|
if (!existingAssignment) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
await pluginData.state.apiPermissionAssignments.removeUser(args.guildId, user.id);
|
||
|
}
|
||
|
|
||
|
const userNameList = args.users.map(
|
||
|
user => `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`,
|
||
|
);
|
||
|
sendSuccessMessage(
|
||
|
pluginData,
|
||
|
msg.channel,
|
||
|
`The following users were removed from the dashboard for **${guild.name}**:\n\n${userNameList}`,
|
||
|
);
|
||
|
},
|
||
|
});
|