diff --git a/src/Nadeko.Medusa/Nadeko.Medusa.csproj b/src/Nadeko.Medusa/Nadeko.Medusa.csproj index 7b152459e..1b227d418 100644 --- a/src/Nadeko.Medusa/Nadeko.Medusa.csproj +++ b/src/Nadeko.Medusa/Nadeko.Medusa.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/NadekoBot/Modules/Administration/UserPunish/UserPunishCommands.cs b/src/NadekoBot/Modules/Administration/UserPunish/UserPunishCommands.cs index 576f59e1c..07ab65b19 100644 --- a/src/NadekoBot/Modules/Administration/UserPunish/UserPunishCommands.cs +++ b/src/NadekoBot/Modules/Administration/UserPunish/UserPunishCommands.cs @@ -722,6 +722,49 @@ public partial class Administration await ctx.Channel.EmbedAsync(toSend); } + + [Cmd] + [RequireContext(ContextType.Guild)] + [UserPerm(GuildPerm.ModerateMembers)] + [BotPerm(GuildPerm.ModerateMembers)] + [Priority(2)] + public async Task Timeout(IUser globalUser, StoopidTime time, [Leftover] string msg = null) + { + var user = await ctx.Guild.GetUserAsync(globalUser.Id); + + if (user is null) + return; + + if (!await CheckRoleHierarchy(user)) + return; + + var dmFailed = false; + + try + { + var dmMessage = GetText(strs.timeoutdm(Format.Bold(ctx.Guild.Name), msg)); + await user.EmbedAsync(_eb.Create(ctx) + .WithPendingColor() + .WithDescription(dmMessage)); + } + catch + { + dmFailed = true; + } + + await user.SetTimeOutAsync(time.Time); + + var toSend = _eb.Create() + .WithOkColor() + .WithTitle("⏳ " + GetText(strs.timedout_user)) + .AddField(GetText(strs.username), user.ToString(), true) + .AddField("ID", user.Id.ToString(), true); + + if (dmFailed) + toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user)); + + await ctx.Channel.EmbedAsync(toSend); + } [Cmd] [RequireContext(ContextType.Guild)] diff --git a/src/NadekoBot/NadekoBot.csproj b/src/NadekoBot/NadekoBot.csproj index 4cf3b660e..51b0519d4 100644 --- a/src/NadekoBot/NadekoBot.csproj +++ b/src/NadekoBot/NadekoBot.csproj @@ -27,7 +27,7 @@ - + diff --git a/src/NadekoBot/data/aliases.yml b/src/NadekoBot/data/aliases.yml index 31c7c0cfa..a9c339d8e 100644 --- a/src/NadekoBot/data/aliases.yml +++ b/src/NadekoBot/data/aliases.yml @@ -960,6 +960,8 @@ banmessagetest: - banmsgtest banmsgreset: - banmsgreset +timeout: + - timeout wait: - wait warnexpire: diff --git a/src/NadekoBot/data/strings/commands/commands.en-US.yml b/src/NadekoBot/data/strings/commands/commands.en-US.yml index 5af8a850e..4dba72a7b 100644 --- a/src/NadekoBot/data/strings/commands/commands.en-US.yml +++ b/src/NadekoBot/data/strings/commands/commands.en-US.yml @@ -312,6 +312,11 @@ kick: args: - "@Someone Get out!" - "\"Some Guy#1234\" Your behaviour is toxic." +timeout: + desc: "Times the user out for the specified amount of time. You may optionally specify a reason, which will be sent to the user." + args: + - "@Someone 3h Shut up!" + - "@Someone 1h30m" mute: desc: "Mutes a mentioned user both from speaking and chatting. You can also specify time string for how long the user should be muted. You can optionally specify a reason." args: diff --git a/src/NadekoBot/data/strings/responses/responses.en-US.json b/src/NadekoBot/data/strings/responses/responses.en-US.json index fc540d718..3d89d8532 100644 --- a/src/NadekoBot/data/strings/responses/responses.en-US.json +++ b/src/NadekoBot/data/strings/responses/responses.en-US.json @@ -28,6 +28,8 @@ "banmsg_default": "No ban message set. Default behavior will be used.", "banned_pl": "banned", "banned_user": "User Banned", + "timeoutdm": "You have been timed out in {0} server.\nReason: {1}", + "timedout_user": "User Timed Out", "remove_roles_pl": "have had their roles removed", "bot_name": "Bot's name changed to {0}", "bot_status": "Bot status changed to {0}",