Ejemplo n.º 1
0
        private async Task HandleMessageReceived(SocketMessage rawMsg)
        {
            // Ignore system messages and messages from bots
            if (!(rawMsg is SocketUserMessage msg) || msg.Author.IsBot)
            {
                return;
            }

            ICommandContext context;

            int argPos = 0;

            if (msg.HasStringPrefix(Global.adminPrefix, ref argPos))
            {
                context = new PrefixCommandContext(Global.adminPrefix, _client, msg);
            }
            else if (msg.HasStringPrefix(Global.userPrefix, ref argPos))
            {
                context = new PrefixCommandContext(Global.userPrefix, _client, msg);
            }
            else
            {
                return;
            }

            IResult result = await _commands.ExecuteAsync(context, argPos, _services, MultiMatchHandling.Best);

            //if (result.Error.HasValue &&
            //    result.Error.Value != CommandError.UnknownCommand)
            //    await context.Channel.SendMessageAsync(result.ToString());
        }
Ejemplo n.º 2
0
        private async Task HandleMessageReceived(SocketMessage _rawMsg)
        {
            // Ignore system messages and messages from bots
            if (!(_rawMsg is SocketUserMessage msg) || msg.Author.IsBot)
            {
                return;
            }

            ICommandContext context;

            int argPos = 0;

            if (msg.HasStringPrefix(Global.AdminPrefix, ref argPos))
            {
                context = new PrefixCommandContext(Global.AdminPrefix, Client, msg);
            }
            else if (msg.HasStringPrefix(Global.UserPrefix, ref argPos))
            {
                context = new PrefixCommandContext(Global.UserPrefix, Client, msg);
            }
            else
            {
                return;
            }

            IResult result = await Commands.ExecuteAsync(context, argPos, Services, MultiMatchHandling.Best);
        }