1 |
rakinar2 |
577 |
/** |
2 |
|
|
* This file is part of SudoBot. |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 2021-2023 OSN Developers. |
5 |
|
|
* |
6 |
|
|
* SudoBot is free software; you can redistribute it and/or modify it |
7 |
|
|
* under the terms of the GNU Affero General Public License as published by |
8 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* SudoBot is distributed in the hope that it will be useful, but |
12 |
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU Affero General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU Affero General Public License |
17 |
|
|
* along with SudoBot. If not, see <https://www.gnu.org/licenses/>. |
18 |
|
|
*/ |
19 |
|
|
|
20 |
|
|
import { Message, User } from "discord.js"; |
21 |
|
|
import Command, { ArgumentType, CommandReturn, ValidationRule } from "../../core/Command"; |
22 |
|
|
import { LegacyCommandContext } from "../../services/CommandManager"; |
23 |
|
|
import { userInfo } from "../../utils/embed"; |
24 |
|
|
|
25 |
|
|
export default class SystemUnbanCommand extends Command { |
26 |
|
|
public readonly name = "systemunban"; |
27 |
|
|
public readonly validationRules: ValidationRule[] = [ |
28 |
|
|
{ |
29 |
|
|
types: [ArgumentType.User], |
30 |
|
|
name: "user", |
31 |
|
|
entity: { |
32 |
|
|
notNull: true |
33 |
|
|
}, |
34 |
|
|
errors: { |
35 |
|
|
"entity:null": "Please provide a valid user!", |
36 |
|
|
required: "Please provide a user to unban!" |
37 |
|
|
} |
38 |
|
|
} |
39 |
|
|
]; |
40 |
|
|
public readonly aliases = ["sysunban"]; |
41 |
|
|
public readonly systemAdminOnly = true; |
42 |
|
|
public readonly supportsInteractions = false; |
43 |
|
|
public readonly description = "Unban a user from using the bot."; |
44 |
|
|
public readonly argumentSyntaxes = ["<User|UserId|UserMention>"]; |
45 |
|
|
|
46 |
|
|
async execute(message: Message, context: LegacyCommandContext): Promise<CommandReturn> { |
47 |
|
|
const { user } = context.parsedNamedArgs as { |
48 |
|
|
user: User; |
49 |
|
|
}; |
50 |
|
|
|
51 |
|
|
if (!this.client.commandManager.isBanned(user.id)) { |
52 |
|
|
await this.error(message, "This user is not banned!"); |
53 |
|
|
return; |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
await this.client.commandManager.removeBan(user.id); |
57 |
|
|
|
58 |
|
|
await message.reply({ |
59 |
|
|
embeds: [ |
60 |
|
|
{ |
61 |
|
|
author: { |
62 |
|
|
icon_url: user.displayAvatarURL(), |
63 |
|
|
name: user.username |
64 |
|
|
}, |
65 |
|
|
color: 0x007bff, |
66 |
|
|
description: `**${user.username}** has been unbanned from the system globally.`, |
67 |
|
|
fields: [ |
68 |
|
|
{ |
69 |
|
|
name: "User", |
70 |
|
|
value: userInfo(user), |
71 |
|
|
inline: true |
72 |
|
|
}, |
73 |
|
|
{ |
74 |
|
|
name: "Responsible System Admin", |
75 |
|
|
value: userInfo(message.author), |
76 |
|
|
inline: true |
77 |
|
|
} |
78 |
|
|
] |
79 |
|
|
} |
80 |
|
|
] |
81 |
|
|
}); |
82 |
|
|
} |
83 |
|
|
} |