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 KickModule : ModuleBase<SocketCommandContext> {
|
|
|
|
|
|
|
|
|
|
[Command("kick")]
|
|
|
|
|
[Summary("Выгоняет пользователя")]
|
|
|
|
|
[Alias("кик")]
|
2021-12-15 09:19:14 +03:00
|
|
|
|
public async Task Run(string user, [Remainder]string reason) {
|
|
|
|
|
var author = Context.Guild.GetUser(Context.User.Id);
|
2021-12-10 14:25:29 +03:00
|
|
|
|
var toKick = Utils.ParseMember(Context.Guild, user).Result;
|
2021-12-15 09:19:14 +03:00
|
|
|
|
await CommandHandler.CheckPermissions(author, GuildPermission.KickMembers);
|
|
|
|
|
await CommandHandler.CheckInteractions(author, toKick);
|
|
|
|
|
KickMember(Context.Guild, Context.Guild.GetUser(Context.User.Id), toKick, reason);
|
2021-12-10 14:25:29 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 09:19:14 +03:00
|
|
|
|
private static async void KickMember(IGuild guild, IGuildUser author, IGuildUser toKick, string reason) {
|
2021-12-10 14:25:29 +03:00
|
|
|
|
var authorMention = author.Mention;
|
|
|
|
|
await Utils.SendDirectMessage(toKick, $"Тебя кикнул {authorMention} на сервере {guild.Name} за " +
|
|
|
|
|
$"{Utils.WrapInline(reason)}");
|
|
|
|
|
|
|
|
|
|
var guildKickMessage = $"({author.Username}#{author.Discriminator}) {reason}";
|
|
|
|
|
await toKick.KickAsync(guildKickMessage);
|
|
|
|
|
var notification = $"{authorMention} выгоняет {toKick.Mention} за {Utils.WrapInline(reason)}";
|
|
|
|
|
await Utils.SilentSendAsync(guild.GetSystemChannelAsync().Result, notification);
|
|
|
|
|
await Utils.SilentSendAsync(Utils.GetAdminLogChannel(), notification);
|
|
|
|
|
}
|
|
|
|
|
}
|