mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-29 18:49:53 +03:00
ton of stuff
- new command handler - multilanguage support - time out support - responses - a ton of stuff
This commit is contained in:
parent
1c9caf6d75
commit
f30485dd71
29 changed files with 1686 additions and 520 deletions
43
Boyfriend/Commands/UnbanCommand.cs
Normal file
43
Boyfriend/Commands/UnbanCommand.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using Discord;
|
||||
using Discord.Commands;
|
||||
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
|
||||
namespace Boyfriend.Commands;
|
||||
|
||||
public class UnbanCommand : Command {
|
||||
public override async Task Run(SocketCommandContext context, string[] args) {
|
||||
var toUnban = await Utils.ParseUser(args[0]);
|
||||
if (context.Guild.GetBanAsync(toUnban.Id) == null)
|
||||
throw new Exception(Messages.UserNotBanned);
|
||||
UnbanUser(context.Guild, context.Channel as ITextChannel, context.Guild.GetUser(context.User.Id), toUnban,
|
||||
Utils.JoinString(args, 1));
|
||||
}
|
||||
|
||||
public static async void UnbanUser(IGuild guild, ITextChannel? channel, IGuildUser author, IUser toUnban,
|
||||
string reason) {
|
||||
await CommandHandler.CheckPermissions(author, GuildPermission.BanMembers);
|
||||
var authorMention = author.Mention;
|
||||
var notification = string.Format(Messages.UserUnbanned, authorMention, toUnban.Mention,
|
||||
Utils.WrapInline(reason));
|
||||
await guild.RemoveBanAsync(toUnban);
|
||||
await Utils.SilentSendAsync(channel, string.Format(Messages.UnbanResponse, toUnban.Mention,
|
||||
Utils.WrapInline(reason)));
|
||||
await Utils.SilentSendAsync(await guild.GetSystemChannelAsync(), notification);
|
||||
await Utils.SilentSendAsync(await Utils.GetAdminLogChannel(guild), notification);
|
||||
}
|
||||
|
||||
public override List<string> GetAliases() {
|
||||
return new List<string> {"unban", "разбан"};
|
||||
}
|
||||
|
||||
public override int GetArgumentsAmountRequired() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public override string GetSummary() {
|
||||
return "Возвращает пользователя из бана";
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue