Make mute/silence default to 5 minutes
This commit is contained in:
parent
b106785ebc
commit
c3b23d150f
|
@ -105,6 +105,7 @@ namespace DeukBot4.MessageHandlers.CommandHandler
|
|||
[Command("mute", PermissionLevel.Helper)]
|
||||
[CommandParameters(ParameterMatcher.ParameterType.User, ParameterMatcher.ParameterType.Timespan)]
|
||||
[CommandParameters(ParameterMatcher.ParameterType.User, ParameterMatcher.ParameterType.Number)]
|
||||
[CommandParameters(ParameterMatcher.ParameterType.User)]
|
||||
[CommandHelp("Silences a user for a set amount of time",
|
||||
"Allows you to mute a user for a set amount of time.\n." +
|
||||
"Usage:\n" +
|
||||
|
@ -146,29 +147,36 @@ namespace DeukBot4.MessageHandlers.CommandHandler
|
|||
await user.AddRoleAsync(silencedRole);
|
||||
|
||||
TimeSpan span;
|
||||
switch (request.Parameters[1].Type)
|
||||
if (request.Parameters.Length == 1)
|
||||
{
|
||||
case ParameterMatcher.ParameterType.Number:
|
||||
var minutes = request.Parameters[1].AsInt();
|
||||
if (!minutes.HasValue)
|
||||
return;
|
||||
span = TimeSpan.FromMinutes(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (request.Parameters[1].Type)
|
||||
{
|
||||
case ParameterMatcher.ParameterType.Number:
|
||||
var minutes = request.Parameters[1].AsInt();
|
||||
if (!minutes.HasValue)
|
||||
return;
|
||||
|
||||
span = TimeSpan.FromMinutes(minutes.Value);
|
||||
break;
|
||||
case ParameterMatcher.ParameterType.Timespan:
|
||||
var sp = TimespanParser.Parse(request.Parameters[1].AsString());
|
||||
if (sp.HasValue)
|
||||
{
|
||||
span = sp.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
span = TimeSpan.FromMinutes(minutes.Value);
|
||||
break;
|
||||
case ParameterMatcher.ParameterType.Timespan:
|
||||
var sp = TimespanParser.Parse(request.Parameters[1].AsString());
|
||||
if (sp.HasValue)
|
||||
{
|
||||
span = sp.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(span);
|
||||
|
|
|
@ -18,16 +18,12 @@ namespace DeukBot4.Utilities
|
|||
{
|
||||
case 's':
|
||||
return TimeSpan.FromSeconds(number);
|
||||
break;
|
||||
case 'm':
|
||||
return TimeSpan.FromMinutes(number);
|
||||
break;
|
||||
case 'h':
|
||||
return TimeSpan.FromHours(number);
|
||||
break;
|
||||
case 'd':
|
||||
return TimeSpan.FromDays(number);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue