Exemplo n.º 1
0
        private async Task HandleMessageCreatedAsync(SocketMessage msg)
        {
            if (!(msg is SocketUserMessage message) || message.Author.IsBot)
            {
                return;
            }

            using (var dctx = new SparkyContext())
            {
                var user = dctx.GetOrCreateUser(msg.Author.Id);

                if (DateTime.UtcNow.Subtract(user.LastMessageAt ?? DateTime.UtcNow.AddMinutes(-2)).TotalMinutes >= 1)
                {
                    user.Points       += 1;
                    user.LastMessageAt = DateTime.UtcNow;
                }

                await dctx.SaveChangesAsync();
            }
            var argPos = 0;

            if (message.HasStringPrefix(Configuration.Get <string>("prefix"), ref argPos) || message.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                var context = new SparkyCommandContext(_client, message, _services);

                await _commands.ExecuteAsync(context, argPos, _services, MultiMatchHandling.Best);
            }
        }
Exemplo n.º 2
0
 public Globals(SparkyCommandContext context, IServiceProvider provider)
 {
     Context  = context;
     Client   = context.Client;
     Provider = provider;
 }