Added .timeout command

This commit is contained in:
Kwoth
2022-08-28 16:16:24 +02:00
parent 9eae27bc15
commit b69e25edf4
6 changed files with 54 additions and 2 deletions

View File

@@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net.Core" Version="3.103.0" />
<PackageReference Include="Discord.Net.Core" Version="3.104.0" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
</ItemGroup>

View File

@@ -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)]

View File

@@ -27,7 +27,7 @@
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.4" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="CsvHelper" Version="28.0.1" />
<PackageReference Include="Discord.Net" Version="3.103.0" />
<PackageReference Include="Discord.Net" Version="3.104.0" />
<PackageReference Include="CoreCLR-NCalc" Version="2.2.110" />
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.57.0.2749" />

View File

@@ -960,6 +960,8 @@ banmessagetest:
- banmsgtest
banmsgreset:
- banmsgreset
timeout:
- timeout
wait:
- wait
warnexpire:

View File

@@ -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:

View File

@@ -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}",