mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-04 21:16:29 +03:00
tired
This commit is contained in:
parent
3fa19a4794
commit
8644f70b14
7 changed files with 158 additions and 37 deletions
26
Boyfriend/Commands/BanModule.cs
Normal file
26
Boyfriend/Commands/BanModule.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
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();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
using Discord.Commands;
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
|
|
23
Boyfriend/Commands/Unban.cs
Normal file
23
Boyfriend/Commands/Unban.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using Discord;
|
||||
using Discord.Commands;
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public class UnbanModule : ModuleBase<SocketCommandContext> {
|
||||
|
||||
[Command("unban")]
|
||||
[Summary("Возвращает пользователя из бана")]
|
||||
[Alias("разбан")]
|
||||
public async Task Run(IUser toBan, TimeSpan duration, [Remainder]string reason)
|
||||
=> await UnbanUser(Context.Guild, Context.User, toBan, reason);
|
||||
|
||||
public async Task UnbanUser(IGuild guild, IUser author, IUser toBan, string reason = "") {
|
||||
var authorMention = author.Mention;
|
||||
await toBan.SendMessageAsync("Тебя разбанил " + authorMention + " за " + reason);
|
||||
await guild.RemoveBanAsync(toBan);
|
||||
await guild.GetSystemChannelAsync().Result.SendMessageAsync(authorMention + " возвращает из бана "
|
||||
+ toBan.Mention + " за " + reason);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue