parent
324360073b
commit
9cf03a1fb4
@ -18,7 +18,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[Group]
|
[Group]
|
||||||
public class UserPunishCommands : NadekoSubmodule
|
public class UserPunishCommands : NadekoSubmodule
|
||||||
{
|
{
|
||||||
private async Task InternalWarn(IGuild guild, ulong userId, string modName, string reason)
|
private async Task<PunishmentAction?> InternalWarn(IGuild guild, ulong userId, string modName, string reason)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(reason))
|
if (string.IsNullOrWhiteSpace(reason))
|
||||||
reason = "-";
|
reason = "-";
|
||||||
@ -34,20 +34,20 @@ namespace NadekoBot.Modules.Administration
|
|||||||
Moderator = modName,
|
Moderator = modName,
|
||||||
};
|
};
|
||||||
|
|
||||||
int warnings;
|
int warnings = 1;
|
||||||
List<WarningPunishment> ps;
|
List<WarningPunishment> ps;
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
ps = uow.GuildConfigs.For(guildId, set => set.Include(x => x.WarnPunishments))
|
ps = uow.GuildConfigs.For(guildId, set => set.Include(x => x.WarnPunishments))
|
||||||
.WarnPunishments;
|
.WarnPunishments;
|
||||||
|
|
||||||
uow.Warnings.Add(warn);
|
warnings += uow.Warnings
|
||||||
|
|
||||||
warnings = uow.Warnings
|
|
||||||
.For(guildId, userId)
|
.For(guildId, userId)
|
||||||
.Where(w => !w.Forgiven && w.UserId == userId)
|
.Where(w => !w.Forgiven && w.UserId == userId)
|
||||||
.Count();
|
.Count();
|
||||||
|
|
||||||
|
uow.Warnings.Add(warn);
|
||||||
|
|
||||||
uow.Complete();
|
uow.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var user = await guild.GetUserAsync(userId);
|
var user = await guild.GetUserAsync(userId);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return;
|
return null;
|
||||||
switch (p.Punishment)
|
switch (p.Punishment)
|
||||||
{
|
{
|
||||||
case PunishmentAction.Mute:
|
case PunishmentAction.Mute:
|
||||||
@ -72,7 +72,10 @@ namespace NadekoBot.Modules.Administration
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return p.Punishment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
@ -89,9 +92,16 @@ namespace NadekoBot.Modules.Administration
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
await InternalWarn(Context.Guild, user.Id, Context.User.ToString(), reason).ConfigureAwait(false);
|
var punishment = await InternalWarn(Context.Guild, user.Id, Context.User.ToString(), reason).ConfigureAwait(false);
|
||||||
|
|
||||||
await ReplyConfirmLocalized("user_warned", Format.Bold(user.ToString())).ConfigureAwait(false);
|
if (punishment == null)
|
||||||
|
{
|
||||||
|
await ReplyConfirmLocalized("user_warned", Format.Bold(user.ToString())).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ReplyConfirmLocalized("user_warned_and_punished", Format.Bold(user.ToString()), Format.Bold(punishment.ToString())).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
@ -146,7 +156,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var name = GetText("warned_on_by", w.DateAdded.Value.ToString("dd.MM.yyy"), w.DateAdded.Value.ToString("HH:mm"), w.Moderator);
|
var name = GetText("warned_on_by", w.DateAdded.Value.ToString("dd.MM.yyy"), w.DateAdded.Value.ToString("HH:mm"), w.Moderator);
|
||||||
if (w.Forgiven)
|
if (w.Forgiven)
|
||||||
name = Format.Strikethrough(name) + GetText("warn_cleared_by", w.ForgivenBy);
|
name = Format.Strikethrough(name) + " " + GetText("warn_cleared_by", w.ForgivenBy);
|
||||||
|
|
||||||
embed.AddField(x => x
|
embed.AddField(x => x
|
||||||
.WithName(name)
|
.WithName(name)
|
||||||
@ -175,7 +185,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
}
|
}
|
||||||
|
|
||||||
await ReplyConfirmLocalized("warnings_cleared",
|
await ReplyConfirmLocalized("warnings_cleared",
|
||||||
(Context.Guild as SocketGuild)?.GetUser(userId)?.ToString() ?? userId.ToString()).ConfigureAwait(false);
|
Format.Bold((Context.Guild as SocketGuild)?.GetUser(userId)?.ToString() ?? userId.ToString())).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
@ -254,9 +264,18 @@ namespace NadekoBot.Modules.Administration
|
|||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string list;
|
||||||
|
if (ps.Any())
|
||||||
|
{
|
||||||
|
list = string.Join("\n", ps.Select(x => $"{x.Count} -> {x.Punishment}"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list = GetText("warnpl_none");
|
||||||
|
}
|
||||||
await Context.Channel.SendConfirmAsync(
|
await Context.Channel.SendConfirmAsync(
|
||||||
GetText("warn_punish_list"),
|
GetText("warn_punish_list"),
|
||||||
string.Join("\n", ps.Select(x => $"{x.Count} -> {x.Punishment}"))).ConfigureAwait(false);
|
list).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
18
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
18
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
@ -1702,6 +1702,15 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to User {0} has been warned and {1} punishment has been applied..
|
||||||
|
/// </summary>
|
||||||
|
public static string administration_user_warned_and_punished {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("administration_user_warned_and_punished", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Username.
|
/// Looks up a localized string similar to Username.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1900,6 +1909,15 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to No punishments set..
|
||||||
|
/// </summary>
|
||||||
|
public static string administration_warnpl_none {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("administration_warnpl_none", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to User {0} from text chat.
|
/// Looks up a localized string similar to User {0} from text chat.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2296,6 +2296,9 @@ Owner ID: {2}</value>
|
|||||||
<data name="administration_user_warned" xml:space="preserve">
|
<data name="administration_user_warned" xml:space="preserve">
|
||||||
<value>User {0} has been warned.</value>
|
<value>User {0} has been warned.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="administration_user_warned_and_punished" xml:space="preserve">
|
||||||
|
<value>User {0} has been warned and {1} punishment has been applied.</value>
|
||||||
|
</data>
|
||||||
<data name="administration_warned_on" xml:space="preserve">
|
<data name="administration_warned_on" xml:space="preserve">
|
||||||
<value>Warned on {0} server</value>
|
<value>Warned on {0} server</value>
|
||||||
</data>
|
</data>
|
||||||
@ -2311,6 +2314,9 @@ Owner ID: {2}</value>
|
|||||||
<data name="administration_warnlog_for" xml:space="preserve">
|
<data name="administration_warnlog_for" xml:space="preserve">
|
||||||
<value>Warnlog for {0}</value>
|
<value>Warnlog for {0}</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="administration_warnpl_none" xml:space="preserve">
|
||||||
|
<value>No punishments set.</value>
|
||||||
|
</data>
|
||||||
<data name="administration_warn_cleared_by" xml:space="preserve">
|
<data name="administration_warn_cleared_by" xml:space="preserve">
|
||||||
<value>cleared by {0}</value>
|
<value>cleared by {0}</value>
|
||||||
</data>
|
</data>
|
||||||
|
Loading…
Reference in New Issue
Block a user