global command cooldown reduced to 750ms on self hosted (still 1500 on public bot). Global command cooldown no longer triggers on any message, only on command.
This commit is contained in:
parent
1c142a0fc5
commit
54ddab13c1
@ -30,7 +30,11 @@ namespace NadekoBot.Services
|
|||||||
}
|
}
|
||||||
public class CommandHandler
|
public class CommandHandler
|
||||||
{
|
{
|
||||||
|
#if GLOBAL_NADEKO
|
||||||
public const int GlobalCommandsCooldown = 1500;
|
public const int GlobalCommandsCooldown = 1500;
|
||||||
|
#else
|
||||||
|
public const int GlobalCommandsCooldown = 750;
|
||||||
|
#endif
|
||||||
|
|
||||||
private readonly DiscordShardedClient _client;
|
private readonly DiscordShardedClient _client;
|
||||||
private readonly CommandService _commandService;
|
private readonly CommandService _commandService;
|
||||||
@ -119,18 +123,18 @@ namespace NadekoBot.Services
|
|||||||
private void LogErroredExecution(SocketUserMessage usrMsg, ExecuteCommandResult exec, SocketTextChannel channel, int ticks)
|
private void LogErroredExecution(SocketUserMessage usrMsg, ExecuteCommandResult exec, SocketTextChannel channel, int ticks)
|
||||||
{
|
{
|
||||||
_log.Warn("Command Errored after {5}s\n\t" +
|
_log.Warn("Command Errored after {5}s\n\t" +
|
||||||
"User: {0}\n\t" +
|
"User: {0}\n\t" +
|
||||||
"Server: {1}\n\t" +
|
"Server: {1}\n\t" +
|
||||||
"Channel: {2}\n\t" +
|
"Channel: {2}\n\t" +
|
||||||
"Message: {3}\n\t" +
|
"Message: {3}\n\t" +
|
||||||
"Error: {4}",
|
"Error: {4}",
|
||||||
usrMsg.Author + " [" + usrMsg.Author.Id + "]", // {0}
|
usrMsg.Author + " [" + usrMsg.Author.Id + "]", // {0}
|
||||||
(channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1}
|
(channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1}
|
||||||
(channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2}
|
(channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2}
|
||||||
usrMsg.Content,// {3}
|
usrMsg.Content,// {3}
|
||||||
exec.Result.ErrorReason, // {4}
|
exec.Result.ErrorReason, // {4}
|
||||||
ticks * oneThousandth // {5}
|
ticks * oneThousandth // {5}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> InviteFiltered(IGuild guild, SocketUserMessage usrMsg)
|
private async Task<bool> InviteFiltered(IGuild guild, SocketUserMessage usrMsg)
|
||||||
@ -196,11 +200,6 @@ namespace NadekoBot.Services
|
|||||||
// track how many messagges each user is sending
|
// track how many messagges each user is sending
|
||||||
UserMessagesSent.AddOrUpdate(usrMsg.Author.Id, 1, (key, old) => ++old);
|
UserMessagesSent.AddOrUpdate(usrMsg.Author.Id, 1, (key, old) => ++old);
|
||||||
|
|
||||||
// Bot will ignore commands which are ran more often than what specified by
|
|
||||||
// GlobalCommandsCooldown constant (miliseconds)
|
|
||||||
if (!UsersOnShortCooldown.Add(usrMsg.Author.Id))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var channel = msg.Channel as SocketTextChannel;
|
var channel = msg.Channel as SocketTextChannel;
|
||||||
var guild = channel?.Guild;
|
var guild = channel?.Guild;
|
||||||
|
|
||||||
@ -367,9 +366,13 @@ namespace NadekoBot.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bot will ignore commands which are ran more often than what specified by
|
||||||
|
// GlobalCommandsCooldown constant (miliseconds)
|
||||||
|
if (!UsersOnShortCooldown.Add(context.Message.Author.Id))
|
||||||
|
return new ExecuteCommandResult(cmd, null, SearchResult.FromError(CommandError.Exception, $"You are on a global cooldown."));
|
||||||
|
|
||||||
if (CmdCdsCommands.HasCooldown(cmd, context.Guild, context.User))
|
if (CmdCdsCommands.HasCooldown(cmd, context.Guild, context.User))
|
||||||
return new ExecuteCommandResult(cmd, null, SearchResult.FromError(CommandError.Exception, $"That command is on cooldown for you."));
|
return new ExecuteCommandResult(cmd, null, SearchResult.FromError(CommandError.Exception, $"That command is on a cooldown for you."));
|
||||||
|
|
||||||
return new ExecuteCommandResult(cmd, null, await commands[i].ExecuteAsync(context, parseResult, dependencyMap));
|
return new ExecuteCommandResult(cmd, null, await commands[i].ExecuteAsync(context, parseResult, dependencyMap));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user