コード例 #1
0
        public async Task MessageReceived(SocketMessage msg)
        {
            if (msg.Author.Id == _client.CurrentUser.Id)
            {
                return;
            }

            var message = msg as SocketUserMessage;

            if (message == null || message.Author.IsBot)
            {
                return;
            }

            var    context = new SocketCommandContext(_client, message);
            string reply   = _cooldown.Check("wordsearch") ? _wordSearch.SearchWord(context.Guild.Id, msg.Content) : null;

            if (reply != null)
            {
                _cooldown.Set("wordsearch");
                await message.Channel.SendMessageAsync(reply);
            }
            int argPos = 0;

            if (!(message.HasCharPrefix('!', ref argPos) ||
                  message.HasMentionPrefix(_client.CurrentUser, ref argPos)))
            {
                return;
            }

            await _commands.ExecuteAsync(context, argPos, _services);
        }