From 111b4bc4654db1e5eb98f7a9670e0cabb116feb5 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 30 Mar 2017 04:35:24 +0200 Subject: [PATCH] .unban added --- .../Commands/LocalizationCommands.cs | 4 +- .../Commands/UserPunishCommands.cs | 45 +++++++++++++++++++ .../Resources/CommandStrings.Designer.cs | 27 +++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 9 ++++ .../Resources/ResponseStrings.Designer.cs | 18 ++++++++ src/NadekoBot/Resources/ResponseStrings.resx | 6 +++ 6 files changed, 107 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/LocalizationCommands.cs b/src/NadekoBot/Modules/Administration/Commands/LocalizationCommands.cs index bc4a0952..707d2af4 100644 --- a/src/NadekoBot/Modules/Administration/Commands/LocalizationCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/LocalizationCommands.cs @@ -24,11 +24,11 @@ namespace NadekoBot.Modules.Administration {"nl-NL", "Dutch, Netherlands"}, {"en-US", "English, United States"}, {"fr-FR", "Français, France"}, - {"de-DE", "German, Germany"}, + {"de-DE", "Deutsch, Deutschland"}, {"he-IL", "Hebrew, Israel" }, {"it-IT", "Italiano, Italia" }, //{"ja-JP", "Japanese, Japan"}, - {"ko-KR", "Korean, South Korea" }, + {"ko-KR", "한국어, 대한민국" }, {"nb-NO", "Norwegian (bokmål), Norway"}, {"pl-PL", "Polski, Polska" }, {"pt-BR", "Português Brasileiro, Brasil"}, diff --git a/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs b/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs index 0f54037f..53479589 100644 --- a/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs @@ -290,6 +290,51 @@ namespace NadekoBot.Modules.Administration .ConfigureAwait(false); } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.BanMembers)] + [RequireBotPermission(GuildPermission.BanMembers)] + public async Task Unban([Remainder]string user) + { + var bans = await Context.Guild.GetBansAsync(); + + var bun = bans.FirstOrDefault(x => x.User.ToString().ToLowerInvariant() == user.ToLowerInvariant()); + + if (bun == null) + { + await ReplyErrorLocalized("user_not_found").ConfigureAwait(false); + return; + } + + await UnbanInternal(bun.User).ConfigureAwait(false); + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.BanMembers)] + [RequireBotPermission(GuildPermission.BanMembers)] + public async Task Unban(ulong userId) + { + var bans = await Context.Guild.GetBansAsync(); + + var bun = bans.FirstOrDefault(x => x.User.Id == userId); + + if (bun == null) + { + await ReplyErrorLocalized("user_not_found").ConfigureAwait(false); + return; + } + + await UnbanInternal(bun.User).ConfigureAwait(false); + } + + private async Task UnbanInternal(IUser user) + { + await Context.Guild.RemoveBanAsync(user).ConfigureAwait(false); + + await ReplyConfirmLocalized("unbanned_user", Format.Bold(user.ToString())).ConfigureAwait(false); + } + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [RequireUserPermission(GuildPermission.KickMembers)] diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index bba6abe1..61163a92 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -8456,6 +8456,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to unban. + /// + public static string unban_cmd { + get { + return ResourceManager.GetString("unban_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unbans a user with the provided user#discrim or id.. + /// + public static string unban_desc { + get { + return ResourceManager.GetString("unban_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}unban kwoth#1234` or `{0}unban 123123123`. + /// + public static string unban_usage { + get { + return ResourceManager.GetString("unban_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to unclaim ucall uc. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 1f236f0a..db8b3f50 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -3240,6 +3240,15 @@ `{0}warn @b1nzy` + + unban + + + Unbans a user with the provided user#discrim or id. + + + `{0}unban kwoth#1234` or `{0}unban 123123123` + warnclear warnc diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index b440fe8a..a8e6ed17 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -1504,6 +1504,15 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to User {0} has been unbanned.. + /// + public static string administration_unbanned_user { + get { + return ResourceManager.GetString("administration_unbanned_user", resourceCulture); + } + } + /// /// Looks up a localized string similar to Undeafen successful.. /// @@ -1585,6 +1594,15 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to User not found.. + /// + public static string administration_user_not_found { + get { + return ResourceManager.GetString("administration_user_not_found", resourceCulture); + } + } + /// /// Looks up a localized string similar to User's role added. /// diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index f8523242..9ef50957 100644 --- a/src/NadekoBot/Resources/ResponseStrings.resx +++ b/src/NadekoBot/Resources/ResponseStrings.resx @@ -2287,6 +2287,12 @@ Owner ID: {2} Reason + + User {0} has been unbanned. + + + User not found. + User {0} has been warned.