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