This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
OctobotStealth/Boyfriend/Commands/BanModule.cs
2021-12-07 23:27:27 +05:00

26 lines
No EOL
1.2 KiB
C#

using Discord;
using Discord.Commands;
// ReSharper disable UnusedType.Global
// ReSharper disable UnusedMember.Global
namespace Boyfriend.Commands;
public class BanModule : ModuleBase<SocketCommandContext> {
[Command("ban")]
[Summary("Банит пользователя")]
[Alias("бан")]
public async Task Run(IUser toBan, TimeSpan duration, [Remainder]string reason)
=> await BanUser(Context.Guild, Context.User, toBan, duration, reason);
public async void BanUser(IGuild guild, IUser author, IUser toBan, TimeSpan duration, string reason = "") {
var authorMention = author.Mention;
await toBan.SendMessageAsync("Тебя забанил " + authorMention + " за " + reason);
await guild.AddBanAsync(toBan, 0, reason);
await guild.GetSystemChannelAsync().Result.SendMessageAsync(authorMention + " банит " + toBan.Mention + " за "
+ reason);
var banTimer = new System.Timers.Timer(duration.Milliseconds);
banTimer.Elapsed += UnbanModule.UnbanUser(guild, author, toBan, "Время наказания истекло").;
banTimer.Start();
}
}