2021-12-10 14:25:29 +03:00
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.Commands;
|
|
|
|
|
// ReSharper disable UnusedType.Global
|
|
|
|
|
// ReSharper disable UnusedMember.Global
|
|
|
|
|
// ReSharper disable ClassNeverInstantiated.Global
|
|
|
|
|
|
|
|
|
|
namespace Boyfriend.Commands;
|
|
|
|
|
|
|
|
|
|
public class UnbanModule : ModuleBase<SocketCommandContext> {
|
|
|
|
|
|
|
|
|
|
[Command("unban")]
|
|
|
|
|
[Summary("Возвращает пользователя из бана")]
|
|
|
|
|
[Alias("разбан")]
|
2021-12-15 22:07:04 +03:00
|
|
|
|
public async Task Run(string user, [Remainder] string reason) {
|
|
|
|
|
var toUnban = await Utils.ParseUser(user);
|
2021-12-15 09:19:14 +03:00
|
|
|
|
if (Context.Guild.GetBanAsync(toUnban.Id) == null)
|
|
|
|
|
throw new Exception("Пользователь не забанен!");
|
|
|
|
|
UnbanUser(Context.Guild, Context.Guild.GetUser(Context.User.Id), toUnban, reason);
|
2021-12-10 14:25:29 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 09:19:14 +03:00
|
|
|
|
public static async void UnbanUser(IGuild guild, IGuildUser author, IUser toUnban, string reason) {
|
|
|
|
|
await CommandHandler.CheckPermissions(author, GuildPermission.BanMembers);
|
2021-12-10 14:25:29 +03:00
|
|
|
|
var authorMention = author.Mention;
|
|
|
|
|
var notification = $"{authorMention} возвращает из бана {toUnban.Mention} за {Utils.WrapInline(reason)}";
|
|
|
|
|
await guild.RemoveBanAsync(toUnban);
|
2021-12-15 22:07:04 +03:00
|
|
|
|
await Utils.SilentSendAsync(await guild.GetSystemChannelAsync(), notification);
|
|
|
|
|
await Utils.SilentSendAsync(await Utils.GetAdminLogChannel(guild), notification);
|
2021-12-10 14:25:29 +03:00
|
|
|
|
}
|
|
|
|
|
}
|