small insignificant internal changes
This commit is contained in:
parent
2e4e317e45
commit
a54880c71f
2 changed files with 0 additions and 18 deletions
src/EllieBot/_common/Services
|
@ -15,15 +15,9 @@ public class CommandHandler : IEService, ICommandHandler
|
||||||
public event Func<IUserMessage, CommandInfo, Task> CommandExecuted = delegate { return Task.CompletedTask; };
|
public event Func<IUserMessage, CommandInfo, Task> CommandExecuted = delegate { return Task.CompletedTask; };
|
||||||
public event Func<CommandInfo, ITextChannel, string, Task> CommandErrored = delegate { return Task.CompletedTask; };
|
public event Func<CommandInfo, ITextChannel, string, Task> CommandErrored = delegate { return Task.CompletedTask; };
|
||||||
|
|
||||||
//userid/msg count
|
|
||||||
public ConcurrentDictionary<ulong, uint> UserMessagesSent { get; } = new();
|
|
||||||
|
|
||||||
public ConcurrentHashSet<ulong> UsersOnShortCooldown { get; } = new();
|
|
||||||
|
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly CommandService _commandService;
|
private readonly CommandService _commandService;
|
||||||
private readonly BotConfigService _bcs;
|
private readonly BotConfigService _bcs;
|
||||||
private readonly IBot _bot;
|
|
||||||
private readonly IBehaviorHandler _behaviorHandler;
|
private readonly IBehaviorHandler _behaviorHandler;
|
||||||
private readonly IServiceProvider _services;
|
private readonly IServiceProvider _services;
|
||||||
private readonly ShardData _shardData;
|
private readonly ShardData _shardData;
|
||||||
|
@ -39,7 +33,6 @@ public class CommandHandler : IEService, ICommandHandler
|
||||||
DbService db,
|
DbService db,
|
||||||
CommandService commandService,
|
CommandService commandService,
|
||||||
BotConfigService bcs,
|
BotConfigService bcs,
|
||||||
IBot bot,
|
|
||||||
IBehaviorHandler behaviorHandler,
|
IBehaviorHandler behaviorHandler,
|
||||||
IServiceProvider services,
|
IServiceProvider services,
|
||||||
ShardData shardData)
|
ShardData shardData)
|
||||||
|
@ -48,7 +41,6 @@ public class CommandHandler : IEService, ICommandHandler
|
||||||
_commandService = commandService;
|
_commandService = commandService;
|
||||||
_bc = bcs.Data;
|
_bc = bcs.Data;
|
||||||
_bcs = bcs;
|
_bcs = bcs;
|
||||||
_bot = bot;
|
|
||||||
_behaviorHandler = behaviorHandler;
|
_behaviorHandler = behaviorHandler;
|
||||||
_db = db;
|
_db = db;
|
||||||
_services = services;
|
_services = services;
|
||||||
|
@ -224,11 +216,6 @@ public class CommandHandler : IEService, ICommandHandler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if !GLOBAL_NADEKO
|
|
||||||
// track how many messages each user is sending
|
|
||||||
UserMessagesSent.AddOrUpdate(usrMsg.Author.Id, 1, (_, old) => ++old);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
var channel = msg.Channel;
|
var channel = msg.Channel;
|
||||||
var guild = (msg.Channel as SocketTextChannel)?.Guild;
|
var guild = (msg.Channel as SocketTextChannel)?.Guild;
|
||||||
|
|
||||||
|
@ -403,10 +390,6 @@ public class CommandHandler : IEService, ICommandHandler
|
||||||
|
|
||||||
var cmd = successfulParses[0].Key.Command;
|
var cmd = successfulParses[0].Key.Command;
|
||||||
|
|
||||||
// Bot will ignore commands which are ran more often than what specified by
|
|
||||||
// GlobalCommandsCooldown constant (miliseconds)
|
|
||||||
if (!UsersOnShortCooldown.Add(context.Message.Author.Id))
|
|
||||||
return (false, null, cmd);
|
|
||||||
//return SearchResult.FromError(CommandError.Exception, "You are on a global cooldown.");
|
//return SearchResult.FromError(CommandError.Exception, "You are on a global cooldown.");
|
||||||
|
|
||||||
var blocked = await _behaviorHandler.RunPreCommandAsync(context, cmd);
|
var blocked = await _behaviorHandler.RunPreCommandAsync(context, cmd);
|
||||||
|
|
|
@ -6,7 +6,6 @@ public interface ICommandHandler
|
||||||
string GetPrefix(ulong? id = null);
|
string GetPrefix(ulong? id = null);
|
||||||
string SetDefaultPrefix(string toSet);
|
string SetDefaultPrefix(string toSet);
|
||||||
string SetPrefix(IGuild ctxGuild, string toSet);
|
string SetPrefix(IGuild ctxGuild, string toSet);
|
||||||
ConcurrentDictionary<ulong, uint> UserMessagesSent { get; }
|
|
||||||
|
|
||||||
Task TryRunCommand(SocketGuild guild, ISocketMessageChannel channel, IUserMessage usrMsg);
|
Task TryRunCommand(SocketGuild guild, ISocketMessageChannel channel, IUserMessage usrMsg);
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue